Unescape Jinja block tags in credential type injectors - #249
Open
blaipr wants to merge 1 commit into
Open
Conversation
An author writes { { in an injector so the expression survives the
role's own templating, and the role turns it back into {{ before the
call. There was no matching rule for { %, so a credential type using
{% if %} or {% for %} in an injector was created with the literal spaced
form and the block never ran on the controller.
Add the same treatment for { %.
This matches the fix upstream in redhat-cop/infra.aap_configuration,
commit 4e861af5, which this role derives from.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
Pull request overview
Fixes credential type injectors preprocessing so authors can escape Jinja block tags ({% ... %}) using the spaced form ({ %) to survive role templating, and have it correctly restored before sending to the controller (matching upstream behavior).
Changes:
- Add an unescape rule for
{ %→{%alongside the existing{ {→{{rule in thecredential_typesrole injector handling. - Add a changelog fragment documenting the bugfix and its impact.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| roles/credential_types/tasks/main.yml | Adds { % unescape via regex_replace so block tags in injectors are restored before the module call. |
| changelogs/fragments/fix-injectors-jinja-block-escaping.yml | Documents the bugfix in the changelog fragment format. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An author writes
{ {in an injector so the expression survives the role's own templating, and the role turns it back into{{before the call. There was no matching rule for{ %, so a credential type using{% if %}or{% for %}in an injector was created with the literal spaced form and the block never ran on the controller.Note on #242
#242 rewrites this same expression, to stop the omit placeholder reaching the module. The two touch the same line and will conflict textually; whichever lands first, the other is a one line rebase. They are separate bugs, so they are separate pull requests.
Upstream applied this only to
injectors, and I kept to that.notification_templates.messagescarries the same{ {rule and no{ %rule, but a notification message body is not a place a block tag is expected, so extending it there would be a change on our own account rather than a port.Upstream
Matches
4e861af5inredhat-cop/infra.aap_configuration(their #1341), the repository this role derives from.Type of Change
Component
The
credential_typesrole,injectors.Checklist
ansible-test sanity) — not run, this changes a role only, no plugin or module codeansible-lintproduction profile,yamllint,antsibull-changelog lint)