Skip to content

klio_core.exceptions.KlioConfigTemplatingException thrown for klio subcommands when templated values are used #178

@fallonchen

Description

@fallonchen

Environment

  • klio* version(s): latest release candidates (klio-*==21.2.0rc1) and latest from master (klio-exec==0.2.2, klio-cli==1.0.5, klio-core==0.2.2)
  • Operating System(s): OSX
  • Python version(s) (python -V): 3.6.9
  • Docker version (if relevant) (docker --version):

Description of the bug

When templated values are used in klio-job.yaml, klio subcommands also need the templated value to be passed in (e.g. you need to run klio message publish --template templated_value=MYVALUE) . Otherwise, a KlioConfigTemplatingException is thrown.

What you expected to happen

I expect the non-run subcommands to run correctly without the templated values being explicitly passed in.

How to reproduce (as minimally and precisely as possible)

Create a klio job: klio job create --use-fnapi --use-defaults --job-type streaming
Add a templated value to your klio-job.yaml:

<!--snip-->
job_config:
  api_key: ${templated_key}
<!--snip-->

Run any klio subcommand that isn't klio job run: klio message publish, klio job create, klio job verify, etc

You should then see a stacktrace like this:

(klio-current) ➜  klio-template-bug-fnapi git:(master) ✗ klio job verify --create-resources                             
Traceback (most recent call last):
  File "/Users/fallon/.pyenv/versions/3.6.9/envs/klio-current/lib/python3.6/site-packages/klio_core/config/_preprocessing.py", line 159, in _apply_templates
    return template.substitute(**templates)
  File "/Users/fallon/.pyenv/versions/3.6.9/lib/python3.6/string.py", line 130, in substitute
    return self.pattern.sub(convert, self.template)
  File "/Users/fallon/.pyenv/versions/3.6.9/lib/python3.6/string.py", line 123, in convert
    return str(mapping[named])
KeyError: 'templated_value'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/fallon/.pyenv/versions/klio-current/bin/klio", line 11, in <module>
    sys.exit(main())
  File "/Users/fallon/.pyenv/versions/3.6.9/envs/klio-current/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/fallon/.pyenv/versions/3.6.9/envs/klio-current/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/fallon/.pyenv/versions/3.6.9/envs/klio-current/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/fallon/.pyenv/versions/3.6.9/envs/klio-current/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/fallon/.pyenv/versions/3.6.9/envs/klio-current/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/fallon/.pyenv/versions/3.6.9/envs/klio-current/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/fallon/.pyenv/versions/3.6.9/envs/klio-current/lib/python3.6/site-packages/klio_core/utils.py", line 228, in wrapper
    raw_overrides=raw_overrides,
  File "/Users/fallon/.pyenv/versions/3.6.9/envs/klio-current/lib/python3.6/site-packages/klio_core/config/core.py", line 101, in __init__
    raw_override_list=raw_overrides or [],
  File "/Users/fallon/.pyenv/versions/3.6.9/envs/klio-current/lib/python3.6/site-packages/klio_core/config/_preprocessing.py", line 241, in process
    raw_config_data, template_dict
  File "/Users/fallon/.pyenv/versions/3.6.9/envs/klio-current/lib/python3.6/site-packages/klio_core/config/_preprocessing.py", line 161, in _apply_templates
    raise exceptions.KlioConfigTemplatingException(e)
klio_core.exceptions.KlioConfigTemplatingException: 'templated_value' missing in key template overrides.

Anthing else we need to know?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions