Skip to content

jinja: fix YAML terminator removal in Jinja's "yaml" filter - #36611

Merged
cachedout merged 1 commit into
saltstack:2015.8from
multani:2015.8
Sep 28, 2016
Merged

cachedout merged 1 commit into
saltstack:2015.8from
multani:2015.8

Conversation

@multani

@multani multani commented Sep 27, 2016 •

Copy link
Copy Markdown
Contributor

The following pillar file:

{% set foo = "bla" %}
test: {{ foo | yaml }}
foo: bar

fails with:

$ salt "minion" saltutil.refresh_pillar
minion:
    True

$ tail /var/log/salt/master
2016-09-27 19:02:59,063 [salt.pillar      ][CRITICAL][1377] Rendering SLS 'test' failed, render error:
expected '<document start>', but found '<block mapping start>'
  in "<unicode string>", line 4, column 1:
    foo: bar
    ^
2016-09-27 19:02:59,113 [salt.pillar      ][CRITICAL][1377] Pillar render error: Rendering SLS 'test' failed. Please see master log for details.

Debugging the whole thing shows that the Jinja file rendered, before the YAML parser has a chance to kick in is (literally):

test: bla
...
foo: bar

Relevant commits: e6acf7b and a7dd113

This is wrong in many ways:

  • the yaml_txt value is strip()-ed so it will not finish by a \n as the test added in e6acf7b expects. So, I guess this warning never show up.
  • the second commit is even worse, as the subtraction is done on the string object, not on the len() call
  • ... and I'm so sad to find such bugs in Salt :/

@multani

multani commented Sep 27, 2016

Copy link
Copy Markdown
Contributor Author

Also, the bug is present on develop, so you may want to frontport (?) it as well.

@cachedout
cachedout merged commit 5de036b into saltstack:2015.8 Sep 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants