Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.16: Do not ignore SyntaxError from jinja2.Environment.from_string (#82607) #82614

Merged
merged 1 commit into from Feb 14, 2024

Conversation

mkrizek
Copy link
Contributor

@mkrizek mkrizek commented Jan 29, 2024

SUMMARY

Backport of #82607

(cherry picked from commit 6d34eb8)

ISSUE TYPE
  • Bugfix Pull Request

…e#82607)

Jinja may generate an invalid Python source code from a template. Trying
to compile such source code into a Python code object results in
SyntaxError being thrown. An example of such a template is providing the
same keyword argument into a lookup twice, resulting in:
`SyntaxError: keyword argument repeated`.

Since `jinja2.exceptions.TemplateSyntaxError` does not cover such a
case, as it is not a Jinja parsing error, we need to catch SyntaxError
explicitly ourselves.

Fixes ansible#82606

(cherry picked from commit 6d34eb8)
@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. backport This PR does not target the devel branch. labels Jan 29, 2024
@webknjaz
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jan 29, 2024
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Feb 13, 2024
@sivel
Copy link
Member

sivel commented Feb 13, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Feb 13, 2024
@sivel sivel merged commit c932343 into ansible:stable-2.16 Feb 14, 2024
78 checks passed
@mkrizek mkrizek deleted the backport/2.16/82607 branch February 15, 2024 08:13
@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Feb 19, 2024
@ansible ansible locked and limited conversation to collaborators Mar 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport This PR does not target the devel branch. bug This issue/PR relates to a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants