Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/69042.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Restore explicit ``import salt.utils.jid`` in the ``pgjsonb`` returner so that ``prep_jid`` and ``get_jids`` no longer rely on the import being pulled in transitively. Without the explicit import, any change to the import chain raised ``AttributeError: module 'salt.utils' has no attribute 'jid'`` and prevented the master from publishing jobs when ``master_job_cache: pgjsonb`` was in use.
1 change: 1 addition & 0 deletions salt/returners/pgjsonb.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
import salt.exceptions
import salt.returners
import salt.utils.data
import salt.utils.jid
import salt.utils.job

try:
Expand Down
20 changes: 20 additions & 0 deletions tests/pytests/unit/returners/test_pgjsonb.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,23 @@ def test_save_load_with_bytes():
with patch.object(psycopg2.extras, "Json") as json_mock:
pgjsonb.save_load(load["jid"], load)
json_mock.assert_called_with(decoded_load)


def test_module_imports_salt_utils_jid_explicitly():
"""
``prep_jid`` and ``get_jids`` reference ``salt.utils.jid.gen_jid`` and
``salt.utils.jid.format_jid_instance``. Prior to the fix the module did
not import ``salt.utils.jid`` itself and only worked because another
salt module transitively loaded it. Refactoring the import chain
silently broke the returner with
``AttributeError: module 'salt.utils' has no attribute 'jid'``.

This regression test asserts that the module-level import is present
so future refactors can no longer drop it.
"""
import salt.utils.jid as utils_jid

# The module's globals must expose the same ``salt.utils.jid`` object
# so that ``salt.utils.jid.gen_jid`` and ``salt.utils.jid.format_jid_instance``
# always resolve regardless of the order in which other salt modules load.
assert pgjsonb.salt.utils.jid is utils_jid
Loading