saltstack / saltstack/salt

JSONDecodeError in rabbitmq.list_user_permissions

Open
#61,091 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Regression severity-medium Silicon v3004.0
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description of Issue

There seems to be a compatibility issue or regression of some sort in Salt 3004 on Ubuntu Server 18.04 LTS with RabbitMQ 3.6.10 (from Ubuntu repository) where the rabbitmq.list_user_permissions module throws a JSONDecodeError exception.

I dug through the release notes and found that the dependency on the --formatter=json flag was introduced as part of the solution to issue #49115 . That fix is great, but I believe the issue is that older versions of rabbitmqctl don't support the --formatter=json option.

I wasn't able to easily determine in the RabbitMQ release notes when the flag was added to rabbitmqctl. I can probably figure it out, but getting a little cross-eyed tonight from looking at other unrelated issues before I hit this one.

My personal workaround is to drop back to < 3004 until my next opportunity to upgrade RabbitMQ since I'm stuck running against these packages for a while. I'm logging mainly to help clarify if the intention was to drop support for older RabbitMQ releases that might still be common in the wild and to give other folks a search result if they run into the same conundrum during a Salt upgrade.

Results from 3003.3:
$ salt --version
salt 3003.3

$ salt-call rabbitmq.list_user_permissions admin
local:
    ----------
    /:
        - .*
        - .*
        - .*
Results from 3004:
$ salt --version
salt 3004

$ salt-call rabbitmq.list_user_permissions admin
[ERROR   ] stderr: Error: operation list_user_permissions used with invalid parameter: ["admin",
                                                                     "--formatter=json"]
[ERROR   ] retcode: 64
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module>
    load_entry_point('salt==3004', 'console_scripts', 'salt-call')()
  File "/usr/lib/python3/dist-packages/salt/scripts.py", line 432, in salt_call
    client.run()
  File "/usr/lib/python3/dist-packages/salt/cli/call.py", line 55, in run
    caller.run()
  File "/usr/lib/python3/dist-packages/salt/cli/caller.py", line 111, in run
    ret = self.call()
  File "/usr/lib/python3/dist-packages/salt/cli/caller.py", line 219, in call
    self.opts, data, func, args, kwargs
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1201, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1216, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/executors/direct_call.py", line 10, in execute
    return func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1201, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1216, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/modules/rabbitmq.py", line 698, in list_user_permissions
    perms = salt.utils.json.loads(res["stdout"])
  File "/usr/lib/python3/dist-packages/salt/utils/json.py", line 89, in loads
    return json_module.loads(s, **kwargs)
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Setup
  • Set up a rabbitmq user
Steps to Reproduce Issue

$ salt-call rabbitmq.list_user_permissions admin

Versions Report
Salt Version:
          Salt: 3004

Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.6.1
     docker-py: Not Installed
         gitdb: 2.0.3
     gitpython: 2.1.8
        Jinja2: 2.10
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 0.5.6
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: 2.6.1
  pycryptodome: 3.4.7
        pygit2: Not Installed
        Python: 3.6.9 (default, Jan 26 2021, 15:33:00)
  python-gnupg: 0.4.1
        PyYAML: 3.12
         PyZMQ: 17.1.2
         smmap: 2.0.3
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.2.5

System Versions:
          dist: ubuntu 18.04 Bionic Beaver
        locale: UTF-8
       machine: x86_64
       release: 4.15.0-156-generic
        system: Linux
       version: Ubuntu 18.04 Bionic Beaver

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in salt/modules/rabbitmq.py at list_user_permissions, where the reported JSONDecodeError occurs, and reproduce the command against RabbitMQ 3.6.10. Check how the unsupported --formatter=json response is handled; done means the module no longer raises JSONDecodeError and returns permissions or a clear compatibility error for this RabbitMQ version.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rabbitmq
Domain
infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.