saltstack / saltstack/salt

[Bug]: zypperpkg does not distinguish stdout/stderr

Open
#69,502 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

What happened?

Below is an example from pkg.list_provides, however the same also breaks state functions such as pkg.installed, due to them calling the same problematic execution functions.

# salt-call pkg.list_provides
[ERROR   ] An un-handled exception was caught by Salt's global exception handler:
ValueError: not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 10, in <module>
    salt_call()
  File "/usr/lib/python3.6/site-packages/salt/scripts.py", line 444, in salt_call
    client.run()
  File "/usr/lib/python3.6/site-packages/salt/cli/call.py", line 59, in run
    caller.run()
  File "/usr/lib/python3.6/site-packages/salt/cli/caller.py", line 95, in run
    ret = self.call()
  File "/usr/lib/python3.6/site-packages/salt/cli/caller.py", line 203, in call
    self.opts, data, func, args, kwargs
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1234, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1249, in _run_as
    ret = _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/executors/direct_call.py", line 10, in execute
    return func(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1234, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1249, in _run_as
    ret = _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/modules/zypperpkg.py", line 3222, in list_provides
    provide, realname = line.split("_|-")
ValueError: not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 10, in <module>
    salt_call()
  File "/usr/lib/python3.6/site-packages/salt/scripts.py", line 444, in salt_call
    client.run()
  File "/usr/lib/python3.6/site-packages/salt/cli/call.py", line 59, in run
    caller.run()
  File "/usr/lib/python3.6/site-packages/salt/cli/caller.py", line 95, in run
    ret = self.call()
  File "/usr/lib/python3.6/site-packages/salt/cli/caller.py", line 203, in call
    self.opts, data, func, args, kwargs
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1234, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1249, in _run_as
    ret = _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/executors/direct_call.py", line 10, in execute
    return func(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1234, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1249, in _run_as
    ret = _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/modules/zypperpkg.py", line 3222, in list_provides
    provide, realname = line.split("_|-")
ValueError: not enough values to unpack (expected 2, got 1)

The breakage is caused because rpm on the affected machine returns a warning message on stderr along with any query operations:

# rpm -q vim
warning: Found NDB Packages.db database while attempting bdb backend: using ndb backend.
vim-9.2.0280-150500.20.46.1.x86_64

# rpm -q vim 2> stderr 1> stdout
# more stderr stdout
::::::::::::::
stderr
::::::::::::::
warning: Found NDB Packages.db database while attempting bdb backend: using ndb backend.
::::::::::::::
stdout
::::::::::::::
vim-9.2.0280-150500.20.46.1.x86_64

Currently, the code mixes output from stdout and stderr. Generally, the query output to be parsed should only be expected on stdout - I think information on stderr should not be included in the same parsing logic.

Of course, the administrator should resolve the warning, but it should not affect the functionality of pkg operations via Salt, as calling zypper manually also works without any issues.

Note the traceback above and the versions output below is with a packaged installation of Salt, as I have a real-life reproducer there, however the same parsing problem is applicable to the upstream code.

I already have a patch for this and will submit it shortly.

Type of salt install

other (please specify in bug details)

Major version

3006.x

What supported OS are you seeing the problem on? Can select multiple. (If bug appears on an unsupported OS, please open a GitHub Discussion instead)

sles-15-sp5

salt --versions-report output
# salt-call --versions-report
Salt Version:
          Salt: 3006.0

Python Version:
        Python: 3.6.15 (default, Apr 27 2026, 16:53:54) [GCC]

Dependency Versions:
          cffi: 1.13.2
      cherrypy: Not Installed
   contextvars: 2.4
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.10.1
       libgit2: Not Installed
  looseversion: 1.0.2
      M2Crypto: 0.44.0
          Mako: Not Installed
       msgpack: 0.5.6
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 21.3
     pycparser: 2.17
      pycrypto: Not Installed
  pycryptodome: Not Installed
        pygit2: Not Installed
  python-gnupg: Not Installed
        PyYAML: 5.4.1
         PyZMQ: 17.1.2
        relenv: Not Installed
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.2.3

System Versions:
          dist: opensuse-leap 15.6
        locale: UTF-8
       machine: x86_64
       release: 6.4.0-150600.23.100-default
        system: Linux
       version: openSUSE Leap 15.6

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/zypperpkg.py at list_provides, especially the parsing around line 3222, and reproduce the failure with pkg.list_provides on the described system. Trace the shared package-operation execution path and verify that query parsing ignores stderr warnings while preserving stdout results and avoiding the reported exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.