salt
salt copied to clipboard
[BUG] yaml filter swallows strict undefined errors
Description
Running an invalid dict access (x['key']
with no key
in x
) through a yaml
filter results in NULL
.
Steps to Reproduce the behavior
The following state:
{%- set ports = {'http': 80} %}
huh:
test.configurable_test_state:
- changes: true
- result: true
- comment: https port is {{ ports['https'] | yaml }}
Results in the following output (notice NULL
):
ID: huh
Function: test.configurable_test_state
Result: True
Comment: https port is NULL
Started: 23:23:20.993192
Duration: 1.049 ms
Removing yaml
filter triggers the error (as one would expect):
local:
Data failed to compile:
----------
Rendering SLS 'base:huh' failed: Jinja variable 'dict object' has no attribute 'https'; line 7
---
[...]
huh:
test.configurable_test_state:
- changes: true
- result: true
- comment: https port is {{ ports['https'] }} <======================
---
Expected behavior
Whether | yaml
is present or not, there should be an error for a missing key.
See: https://github.com/pallets/jinja/blob/3.1.2/src/jinja2/runtime.py#L1020
Versions Report
salt --versions-report
Salt Version:
Salt: 3005.1alpha0+cf7
Dependency Versions:
cffi: 1.15.1
cherrypy: Not Installed
dateutil: 2.8.2
docker-py: 5.0.3
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.2
libgit2: Not Installed
M2Crypto: 0.38.0
Mako: Not Installed
msgpack: 1.0.3
msgpack-pure: Not Installed
mysql-python: Not Installed
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.11.0
pygit2: Not Installed
Python: 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]
python-gnupg: Not Installed
PyYAML: 6.0
PyZMQ: 24.0.1
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.4
System Versions:
dist: debian 12 bookworm
locale: utf-8
machine: x86_64
release: 6.1.38-cloudflare-2023.7.3
system: Linux
version: Debian GNU/Linux 12 bookworm