Skip to content

[BUG] [3006.0] Regression: Include sls that includes jinja macros leads to Rendering SLS error #64111

Closed
@babs

Description

Description

Include of sls that includes jinja macros leads to Rendering SLS 'base:common.file1' failed: Jinja error: 'NoneType' object has no attribute 'done'
Regression introduced in 3006.0, working fine on 3005.1 and previous.

state.apply common gives the following error while state.apply common.file1 works fine.

local:
    Data failed to compile:
----------
    Rendering SLS 'base:common.file1' failed: Jinja error: 'NoneType' object has no attribute 'done'
Traceback (most recent call last):
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/templates.py", line 471, in render_jinja_tmpl
    output = template.render(**decoded_context)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/opt/saltstack/salt/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/jinja.py", line 185, in get_source
    self.check_cache(_template)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/jinja.py", line 138, in check_cache
    ret = self.cache_file(template)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/jinja.py", line 131, in cache_file
    return fcl.get_file(saltpath, "", True, self.saltenv)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/fileclient.py", line 1167, in get_file
    hash_server, stat_server = self.hash_and_stat_file(path, saltenv)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/fileclient.py", line 1414, in hash_and_stat_file
    hash_result = self.hash_file(path, saltenv)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/fileclient.py", line 1407, in hash_file
    return self.__hash_and_stat_file(path, saltenv)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/fileclient.py", line 1399, in __hash_and_stat_file
    return self.channel.send(load)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/asynchronous.py", line 125, in wrap
    raise exc_info[1].with_traceback(exc_info[2])
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/asynchronous.py", line 131, in _target
    result = io_loop.run_sync(lambda: getattr(self.obj, key)(*args, **kwargs))
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/ext/tornado/ioloop.py", line 457, in run_sync
    if not future_cell[0].done():
AttributeError: 'NoneType' object has no attribute 'done'

; line 1

---
{% from 'common/macros.jinja' import a_jinja_macro with context %}    <======================

a state id:
  cmd.run:
    - name: echo {{ a_jinja_macro("hello world") }}

[...]
---

Setup

One master and one minion running 3006.

  • VM (vmware)
  • onedir packaging

Steps to Reproduce the behavior

On the master side in a common folder:

  • macros.jinja
    {% macro a_jinja_macro(arg) -%}
    {{ arg }}
    {%- endmacro %}
    
  • init.sls
    include:
    - common.file1
    
  • file1.sls
    {% from 'common/macros.jinja' import a_jinja_macro with context %}
    
    a state id:
      cmd.run:
        - name: echo {{ a_jinja_macro("hello world") }}
    
    

Expected behavior

On the minion side as from the master side, being able to call state.apply common without issue (as it was on 3005.1 and previous)

local:
----------
          ID: a state id
    Function: cmd.run
        Name: echo hello world
      Result: True
     Comment: Command "echo hello world" run
     Started: 15:58:45.411296
    Duration: 5.243 ms
     Changes:   
              ----------
              pid:
                  1259842
              retcode:
                  0
              stderr:
              stdout:
                  hello world

Summary for local
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time:   5.243 ms

Versions Report

salt --versions-report
Salt Version:
          Salt: 3006.0
 
Python Version:
        Python: 3.10.11 (main, Apr 14 2023, 05:57:16) [GCC 11.2.0]
 
Dependency Versions:
          cffi: 1.14.6
      cherrypy: unknown
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.2
       libgit2: Not Installed
  looseversion: 1.0.2
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 22.0
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.9.8
        pygit2: Not Installed
  python-gnupg: 0.4.8
        PyYAML: 5.4.1
         PyZMQ: 23.2.0
        relenv: 0.11.2
         smmap: Not Installed
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: debian 11 bullseye
        locale: utf-8
       machine: x86_64
       release: 5.10.0-21-amd64
        system: Linux
       version: Debian GNU/Linux 11 bullseye

Metadata

Assignees

Labels

Bugbroken, incorrect, or confusing behaviorRegressionThe issue is a bug that breaks functionality known to work in previous releases.Sulfur v3006.1

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions