fix: Correctly return exit status 1 when no packages are found - #2705
Merged
Conversation
Contributor
Author
|
@Jguer could you please review the PR and let me know if anything needs to be changed? |
Owner
|
I'm afraid this change breaks a bunch of CI users relying on yay's ignore and keep building. But since it's covering only the 100% coverage case, let's try it out. |
Jguer
approved these changes
Dec 21, 2025
This was referenced Mar 20, 2026
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.
Fixes #2701
Summary
This commit addresses the issue where
yay -S <unknown-package>returns an exit status of0(Success) even though the package resolution failed. This violates standard Unix conventions for scripting and automation, as shell scripts rely on non-zero exit codes to detect failure.Technical Rationale
The root cause was traced to the
GraphFromAURfunction inpkg/depreturning anilerror when all package targets failed to resolve, as it considered the search operation itself successful.The fix implements the following changes:
ErrTargetNotFound, was defined inpkg/query/errors.goto provide a specific, translatable error type for this failure mode.pkg/dep/dep_graph.go, a counter (packagesNotFound) now tracks the number of targets that failed to be resolved in the AUR.packagesNotFound == len(targets)),GraphFromAURnow returns&query.ErrTargetNotFound{}.This non-nil error correctly bubbles up through the execution stack to
cmd/main.go, ensuring the program triggers the essentialos.Exit(1)signal to the shell.Verification Steps
The behavior was confirmed to be fixed using a local development build:
**Before Fix **

After Fix