What happened?
Description
The salt.returners.pgjsonb module references salt.utils.jid.gen_jid()
in prep_jid() and salt.utils.jid.format_jid_instance() in
get_jids(), but does not import salt.utils.jid itself. Both calls
currently work only as a side effect: salt.utils.args (transitively
pulled in via salt.utils.data, which the module does import) loads
salt.utils.jid. Any refactor of that import chain silently breaks
pgjsonb with AttributeError: module 'salt.utils' has no attribute 'jid'.
prep_jid() is called from master.py:_prep_jid() on every job
publish; that caller only handles KeyError, TypeError, so an
AttributeError there propagates up and prevents the master from
publishing jobs.
This was introduced in 3006.x when the explicit import salt.utils.jid
was dropped during the migration from salt.utils.jid to
salt.utils.data / salt.utils.job for decode() and
get_keep_jobs_seconds(). The two salt.utils.jid.* call sites were
overlooked. The bug is present on 3006.x, 3007.x, 3008.x and
master — git diff between any of those branches for this file
shows no change to the relevant lines.
Setup
Any deployment that uses master_job_cache: pgjsonb or invokes
salt-run jobs.list_jobs (which calls get_jids()) is at risk; the
visible failure mode depends on whether salt.utils.args happens to
be loaded before salt.returners.pgjsonb in the running process.
Steps to Reproduce the behavior
In a clean Python interpreter:
import sys
import importlib
import salt.returners.pgjsonb as pgjsonb
import salt.utils
# Detach salt.utils.jid from the package and from sys.modules to
# simulate an environment where it was not transitively loaded.
delattr(salt.utils, "jid")
sys.modules.pop("salt.utils.jid", None)
# Reload pgjsonb so its import block re-executes in the cleaned env.
importlib.reload(pgjsonb)
pgjsonb.__opts__ = {}
pgjsonb.prep_jid()
# AttributeError: module 'salt.utils' has no attribute 'jid'
The same AttributeError is reachable through get_jids() because
it calls salt.utils.jid.format_jid_instance().
Expected behavior
prep_jid() and get_jids() succeed regardless of which other
modules have been imported beforehand in the process.
Additional context
The module already imports salt.utils.data and salt.utils.job
explicitly. The minimal fix is to add import salt.utils.jid between
them. Trace of how salt.utils.jid enters sys.modules today, when
it does:
salt.utils.data → salt.utils.args → salt.utils.jid
If salt.utils.args ever stops importing salt.utils.jid at module
load time (e.g. lazy-import refactor), pgjsonb breaks silently in
production.
Type of salt install
Official deb
Major version
3006.x, 3007.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)
debian-11, debian-12
salt --versions-report output
salt --versions-report
Salt Version:
Salt: 3007.13
Python Version:
Python: 3.10.19 (main, Feb 5 2026, 07:05:38) [GCC 11.2.0]
Dependency Versions:
cffi: 2.0.0
cherrypy: unknown
cryptography: 42.0.5
dateutil: 2.8.2
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.6
libgit2: 1.9.1
looseversion: 1.3.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.7
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 24.0
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.19.1
pygit2: 1.18.2
python-gnupg: 0.5.2
PyYAML: 6.0.1
PyZMQ: 25.1.2
relenv: 0.22.3
smmap: Not Installed
timelib: 0.3.0
Tornado: 6.5.4
ZMQ: 4.3.4
Salt Extensions:
saltext.vault: 1.5.0
Salt Package Information:
Package Type: onedir
System Versions:
dist: debian 12.13 bookworm
locale: utf-8
machine: x86_64
release: 6.12.73+deb12-amd64
system: Linux
version: Debian GNU/Linux 12.13 bookworm
What happened?
Description
The
salt.returners.pgjsonbmodule referencessalt.utils.jid.gen_jid()in
prep_jid()andsalt.utils.jid.format_jid_instance()inget_jids(), but does notimport salt.utils.jiditself. Both callscurrently work only as a side effect:
salt.utils.args(transitivelypulled in via
salt.utils.data, which the module does import) loadssalt.utils.jid. Any refactor of that import chain silently breakspgjsonb with
AttributeError: module 'salt.utils' has no attribute 'jid'.prep_jid()is called frommaster.py:_prep_jid()on every jobpublish; that caller only handles
KeyError, TypeError, so anAttributeErrorthere propagates up and prevents the master frompublishing jobs.
This was introduced in 3006.x when the explicit
import salt.utils.jidwas dropped during the migration from
salt.utils.jidtosalt.utils.data/salt.utils.jobfordecode()andget_keep_jobs_seconds(). The twosalt.utils.jid.*call sites wereoverlooked. The bug is present on
3006.x,3007.x,3008.xandmaster—git diffbetween any of those branches for this fileshows no change to the relevant lines.
Setup
Any deployment that uses
master_job_cache: pgjsonbor invokessalt-run jobs.list_jobs(which callsget_jids()) is at risk; thevisible failure mode depends on whether
salt.utils.argshappens tobe loaded before
salt.returners.pgjsonbin the running process.Steps to Reproduce the behavior
In a clean Python interpreter:
The same
AttributeErroris reachable throughget_jids()becauseit calls
salt.utils.jid.format_jid_instance().Expected behavior
prep_jid()andget_jids()succeed regardless of which othermodules have been imported beforehand in the process.
Additional context
The module already imports
salt.utils.dataandsalt.utils.jobexplicitly. The minimal fix is to add
import salt.utils.jidbetweenthem. Trace of how
salt.utils.jidenterssys.modulestoday, whenit does:
If
salt.utils.argsever stops importingsalt.utils.jidat moduleload time (e.g. lazy-import refactor), pgjsonb breaks silently in
production.
Type of salt install
Official deb
Major version
3006.x, 3007.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)
debian-11, debian-12
salt --versions-report output
salt --versions-report Salt Version: Salt: 3007.13 Python Version: Python: 3.10.19 (main, Feb 5 2026, 07:05:38) [GCC 11.2.0] Dependency Versions: cffi: 2.0.0 cherrypy: unknown cryptography: 42.0.5 dateutil: 2.8.2 docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed Jinja2: 3.1.6 libgit2: 1.9.1 looseversion: 1.3.0 M2Crypto: Not Installed Mako: Not Installed msgpack: 1.0.7 msgpack-pure: Not Installed mysql-python: Not Installed packaging: 24.0 pycparser: 2.21 pycrypto: Not Installed pycryptodome: 3.19.1 pygit2: 1.18.2 python-gnupg: 0.5.2 PyYAML: 6.0.1 PyZMQ: 25.1.2 relenv: 0.22.3 smmap: Not Installed timelib: 0.3.0 Tornado: 6.5.4 ZMQ: 4.3.4 Salt Extensions: saltext.vault: 1.5.0 Salt Package Information: Package Type: onedir System Versions: dist: debian 12.13 bookworm locale: utf-8 machine: x86_64 release: 6.12.73+deb12-amd64 system: Linux version: Debian GNU/Linux 12.13 bookworm