Project

General

Profile

Bug #14179

Jinja templating iteration example in the doc is invalid

Added by Félix DALLIDET 5 months ago. Updated 5 months ago.

Status:
Released
Priority:
N/A
Category:
Documentation
Target version:
Severity:
User visibility:
Effort required:
Priority:
0

Description

I applied the jinja template from the doc and it fails with the following error:

E| error         jinja                     File from a jinja2 templ| /tmp/result        Build file /tmp/result from template /tmp/template could not be repaired
R: Templating error: Traceback (most recent call last):
  File "/var/rudder/cfengine-community/modules/templates/jinja2-templating.py", line 117, in <module>
    main()
  File "/var/rudder/cfengine-community/modules/templates/jinja2-templating.py", line 113, in main
    render(opts, args)
  File "/var/rudder/cfengine-community/modules/templates/jinja2-templating.py", line 92, in render
    output = env.get_template(os.path.basename(template_path)).render(data)
  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 "/tmp/template", line 17, in top-level template code
    {% for key, value in vars.variable_prefix.dict_name.properties %}
ValueError: too many values to unpack

Associated revisions

Revision d53eb629 (diff)
Added by Félix DALLIDET 5 months ago

Fixes #14179: Jinja templating from the doc fails everytime

History

#1

Updated by Félix DALLIDET 5 months ago

  • Category changed from Generic methods to Documentation

This seems to come from the dict namespace: "variable_prefix" which already exists in rudder and should not be used.

#2

Updated by Félix DALLIDET 5 months ago

And we need an iterator call for the last block aka .item() on the last for block

#3

Updated by Félix DALLIDET 5 months ago

  • Status changed from New to In progress
  • Assignee set to Félix DALLIDET
#4

Updated by Félix DALLIDET 5 months ago

  • Status changed from In progress to Pending technical review
  • Assignee changed from Félix DALLIDET to Alexis MOUSSET
  • Pull Request set to https://github.com/Normation/ncf/pull/900
#5

Updated by Félix DALLIDET 5 months ago

  • Status changed from Pending technical review to Pending release
#6

Updated by Alexis MOUSSET 5 months ago

  • Subject changed from Jinja templating from the doc fails everytime to Jinja templating iteration example in the doc is invalid
#7

Updated by Alexis MOUSSET 5 months ago

  • Status changed from Pending release to Released
This bug has been fixed in Rudder 4.1.19, 4.3.9 and 5.0.5 which were released today.
Changelog
Changelog
Changelog

Also available in: Atom PDF