Skip to content

zypperpkg: stop logging a spurious ERROR on zypper exit code 104 (nothing found)#69758

Open
ggiesen wants to merge 1 commit into
saltstack:3006.xfrom
ggiesen:fix-58551
Open

zypperpkg: stop logging a spurious ERROR on zypper exit code 104 (nothing found)#69758
ggiesen wants to merge 1 commit into
saltstack:3006.xfrom
ggiesen:fix-58551

Conversation

@ggiesen

@ggiesen ggiesen commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Whitelists zypper's exit code 104 (nothing found) for the search-style calls in the zypperpkg execution module so they no longer emit a spurious ERROR log entry when a search matches nothing.

What issues does this PR fix or reference?

Fixes #58551

Previous Behavior

When pkg.search() (or the internal pattern/patch/version searches) matched nothing, zypper exited with code 104. cmd.run_all's default success_retcodes is [0], so cmdmod._run logged Command '...' failed with return code: 104 even though the search completed normally and correctly reported that nothing was found. The 104 was purely cosmetic log noise; the search itself worked (it uses .noraise and raises CommandExecutionError only via its own empty-solvables check).

New Behavior

The _Zypper wrapper gained an ignore_not_found option that whitelists 104 through cmd.run_all's success_retcodes for the four search-style call sites (search, _get_visible_patterns, _get_patches, and Wildcard._get_available_versions). cmdmod remaps 104 to 0 before its retcode-error log fires, so no ERROR is emitted. The found case (retcode 0) and every genuine error code are left untouched, and a search that matches nothing still raises CommandExecutionError as before.

Note: unlike the earlier closed PR #58552, this change keeps the -x (exact-match) flag on the se -xv call in _get_available_versions; dropping it to se -v is an unrelated semantic change (substring vs exact match) and is out of scope here.

Merge requirements satisfied?

  • Docs - n/a (no user-facing interface or behaviour change; log noise only)
  • Changelog - changelog/58551.fixed.md
  • Tests written/updated

Tests added to tests/unit/modules/test_zypperpkg.py:

  • test_search - asserts search() invokes __zypper__(root=None, ignore_not_found=True).
  • test_search_not_found_58551 - production-exact reproducer: with cmd.run_all returning retcode 104, search() still raises CommandExecutionError (empty result) and cmd.run_all is called with success_retcodes=[104], proving 104 is whitelisted so no ERROR is logged.
  • test_search_without_ignore_not_found_still_errors - inverse guard: a _Zypper call that does not request ignore_not_found must not pass success_retcodes, so genuine non-zero retcodes still surface (passes with and without the fix).

The existing Wildcard tests and ZyppCallMock were updated to match the new self.zypper(ignore_not_found=True) call shape.

Commits signed with GPG?

No

zypper returns exit code 104 when a search matches nothing. The
search-style calls in zypperpkg (search, _get_visible_patterns,
_get_patches, and Wildcard._get_available_versions) run through
cmd.run_all, whose default success_retcodes is [0], so the 104 was
logged as a command failure even though the search itself completed
normally and correctly reported that nothing was found.

Add an ignore_not_found option to the _Zypper wrapper that whitelists
104 via success_retcodes for those search calls, so the exit code is
treated as success and no ERROR is emitted. The found case (0) and all
genuine error codes are left untouched.

Fixes saltstack#58551
@ggiesen ggiesen requested a review from a team as a code owner July 10, 2026 17:25
@charzl charzl self-assigned this Jul 10, 2026
@dwoz dwoz added the test:full Run the full test suite label Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants