Skip to content

Conversation

@jeremystretch
Copy link
Member

Closes: #18797

Adds support for dotted path imports for Jinja environment params undefined and finalize, for both config templates and export templates.

  • Introduce and utilize the new get_environment_params() method on RenderTemplateMixin

@jeremystretch jeremystretch requested review from a team and jnovinger and removed request for a team July 28, 2025 13:44
Copy link
Member

@jnovinger jnovinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a couple of questions. Given new behavior, would love to see some testing. Lastly, is it worth mentioning this in the docs somewhere? Perhaps even in just the ConfigTemplate model docs for the environment params field.

for name, value in params.items():
if name in JINJA_ENV_PARAMS_WITH_PATH_IMPORT and type(value) is str:
params[name] = import_string(value)
return params
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of questions here:

  1. Should we do any validation of value? E.g. make sure it's within a set of accepted values?
  2. I assume import_string() might raise some exceptions, especially around dotted-paths that don't exist. Is the intention to let those bubble up to the user?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. What would the valid values be? I don't think we have a way of knowing, unless we limited it to a very small, prescribed set of choices.
  2. Yes; exceptions will be raised to surface the invalid configuration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

@jeremystretch
Copy link
Member Author

Given new behavior, would love to see some testing.

Unfortunately there's no existing test case for this functionality which can be expanded to cover the modest addition in functionality. I've opened #19971 for new test cases to be added, but it's beyond the scope of this FR IMO.

@jeremystretch jeremystretch requested a review from jnovinger July 29, 2025 12:56
@jnovinger jnovinger merged commit 063d1fe into main Jul 29, 2025
7 checks passed
@jnovinger jnovinger deleted the 18797-jinja2-env-paths branch July 29, 2025 14:09
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config Template Rendering: Option for jinja2.StrictUndefined

3 participants