Skip to content

[BUG] TypeError: object of type 'NoneType' has no len() #259

@arthurzenika

Description

@arthurzenika

Your setup

Formula commit hash / release tag

e8ed39a

Versions reports (master & minion)

Salt Version:
           Salt: 2019.2.2
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.5.3
      docker-py: Not Installed
          gitdb: 2.0.0
      gitpython: 2.1.1
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.13 (default, Nov 24 2017, 17:33:09)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: 2.0.1
        timelib: Not Installed
        Tornado: 4.4.3
            ZMQ: 4.2.1
 
System Versions:
           dist: debian 9.5 
         locale: UTF-8
        machine: x86_64
        release: 4.9.0-7-amd64
         system: Linux
        version: debian 9.5 


Bug details

Describe the bug

    Function: file.managed
        Name: /etc/nginx/sites-available/francearchives
      Result: False
     Comment: Unable to manage file: Jinja error: object of type 'NoneType' has no len()
              Traceback (most recent call last):
                File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 394, in render_jinja_tmpl
                  output = template.render(**decoded_context)
                File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
                  return self.environment.handle_exception(exc_info, True)
                File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
                  reraise(exc_type, exc_value, tb)
                File "<template>", line 29, in top-level template code
                File "<template>", line 10, in template
              TypeError: object of type 'NoneType' has no len()
              
              ; line 10
              
              ---
              [...]
              {{ key|indent(ind, True) }}{{ operator }}{{ value }}{{ delim }}{{ lb }}
                      {%- elif value is mapping -%}
                          {%- for k, v in value.items() -%}
                              {%- if v is number or v is string -%}
              {{ server_config([v], k, ind) }}
                              {%- elif v|length() > 0 and (v[0] is number or v[0] is string) -%}    <======================
              {{ server_config(v, k, ind) }}
                              {%- else -%}
              {{ lb }}{{ k|indent(ind, True) }} {{ '{' }}
              {{ server_config(v, '', ind + ind_increment) -}}
              {{ '}'|indent(ind, True) }}{{ lb }}
              [...]
              ---


Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions