Skip to content

[BUG] 3003 broken pillar json serializable  #60083

Closed

Description

@fangpsh

Description
3003 broken pillar json serializable, works fine in 3002.6

Setup

default config.

Steps to Reproduce the behavior

example.sls

/etc/metadata:
    file.managed:
        - user: root
        - group: root
        - mode: 0644
        - contents: |
            {{pillar|json}}

Screenshots

local:
    Data failed to compile:
----------
    Rendering SLS 'base:base.metadata' failed: Jinja error: Object of type 'NamedLoaderContext' is not JSON serializable
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/utils/templates.py", line 497, in render_jinja_tmpl
    output = template.render(**decoded_context)
  File "/usr/lib/python3.6/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/lib/python3.6/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/lib/python3.6/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 15, in top-level template code
  File "/usr/lib/python3.6/site-packages/salt/utils/jinja.py", line 936, in format_json
    value, sort_keys=sort_keys, indent=indent
  File "/usr/lib/python3.6/site-packages/salt/utils/json.py", line 149, in dumps
    return json_module.dumps(obj, **kwargs)  # future lint: blacklisted-function
  File "/usr/lib64/python3.6/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib64/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib64/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib64/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'NamedLoaderContext' is not JSON serializable

; line 15

---
[...]
    file.managed:
        - user: root
        - group: root
        - mode: 0644
        - contents: |
            {{pillar|json}}    <======================

[...]

Versions Report

salt --versions-report
Salt Version:
          Salt: 3003

Dependency Versions:
          cffi: Not Installed
      cherrypy: unknown
      dateutil: Not Installed
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.11.1
       libgit2: Not Installed
      M2Crypto: 0.35.2
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: 2.6.1
  pycryptodome: Not Installed
        pygit2: Not Installed
        Python: 3.6.8 (default, Apr  2 2020, 13:34:55)
  python-gnupg: Not Installed
        PyYAML: 3.12
         PyZMQ: 17.0.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.1.4

System Versions:
          dist: centos 7 Core
        locale: UTF-8
       machine: x86_64
       release: 3.10.0-957.21.3.el7.x86_64
        system: Linux
       version: CentOS Linux 7 Core

Activity

  1. added
    bug
    on Apr 26, 2021
  2. welcome commented on Apr 26, 2021

    @welcome

    Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
    Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

    There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
    If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!

  3. added
    Regression
    on Apr 26, 2021
  4. OrangeDog commented on Apr 27, 2021

    @OrangeDog
    Contributor

    As a workaround you can use salt["pillar.raw"]() instead

  5. added
    severity-medium
    and removed on Apr 27, 2021
  6. added this to the Approved milestone on Apr 27, 2021
  7. modified the milestones: Approved, Silicon on Apr 27, 2021
  8. sagetherage commented on Apr 27, 2021

    @sagetherage
    Contributor

    similar issue both could be reviewed at once #59361

  9. dwoz commented on May 11, 2021

    @dwoz
    Contributor

    I don't think #59361 is related.

  10. 9 remaining items

  11. added a commit that references this issue on Jun 23, 2021
  12. added a commit that references this issue on Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

AluminiumLoaderRegressionbugpoint-releaseseverity-medium

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions