Repository navigation
zypperpkg: stop logging a spurious ERROR on zypper exit code 104 (nothing found) - #69758
Merged
Merged
Conversation
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
twangboy
approved these changes
Jul 15, 2026
dwoz
approved these changes
Jul 26, 2026
This was referenced Oct 23, 2026
[Bug]: 3008.x is missing 36 3006.x PRs dropped in the 3007.x -> 3008.x merge-forward (#70132)
#70542
Closed
dwoz
pushed a commit
that referenced
this pull request
Oct 28, 2026
* Silence spurious ERROR log from zypperpkg search on exit code 104 (#69758) 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 #58551 Restores #69758 on 3008.x. It was dropped by the 3007.x merge-forward #70132 and isn't in the #70572 restore (#70542). The 3008.3 release notes already have the changelog entry, so there is no new fragment. (cherry picked from commit a9aa0bd) * Keep test_search_not_found_58551 off the host's rpm lock The mocked cmd.run_all returns 104 as-is, where the real one remaps it to 0, so _check_result treats it as an error and _is_rpm_lock opens /var/lib/rpm/.rpm.lock. Run as a normal user on an RPM-based host, the test fails with PermissionError. Patch _is_rpm_lock like the other non-zero retcode tests in this file.
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 defaultsuccess_retcodesis[0], socmdmod._runloggedCommand '...' failed with return code: 104even 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.noraiseand raisesCommandExecutionErroronly via its own empty-solvables check).New Behavior
The
_Zypperwrapper gained anignore_not_foundoption that whitelists 104 throughcmd.run_all'ssuccess_retcodesfor the four search-style call sites (search,_get_visible_patterns,_get_patches, andWildcard._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 raisesCommandExecutionErroras before.Note: unlike the earlier closed PR #58552, this change keeps the
-x(exact-match) flag on these -xvcall in_get_available_versions; dropping it tose -vis an unrelated semantic change (substring vs exact match) and is out of scope here.Merge requirements satisfied?
changelog/58551.fixed.mdTests added to
tests/unit/modules/test_zypperpkg.py:test_search- assertssearch()invokes__zypper__(root=None, ignore_not_found=True).test_search_not_found_58551- production-exact reproducer: withcmd.run_allreturning retcode 104,search()still raisesCommandExecutionError(empty result) andcmd.run_allis called withsuccess_retcodes=[104], proving 104 is whitelisted so no ERROR is logged.test_search_without_ignore_not_found_still_errors- inverse guard: a_Zyppercall that does not requestignore_not_foundmust not passsuccess_retcodes, so genuine non-zero retcodes still surface (passes with and without the fix).The existing
Wildcardtests andZyppCallMockwere updated to match the newself.zypper(ignore_not_found=True)call shape.Commits signed with GPG?
No