fix(keychain)!: return empty map from Filter on Linux when nothing matches - #605
Merged
Conversation
…tches The Linux Secret Service backend's Filter treated zero matches as store.ErrCredentialNotFound, both when the collection search returned no items and when items existed but none survived pattern matching. The macOS and Windows backends return an empty map with a nil error in the same situation, and 4a163cd already aligned GetAllMetadata the same way. Drop both guards and document the contract on store.Store.Filter: a pattern matching nothing is a valid empty result, not a miss. ErrCredentialNotFound stays reserved for single-item lookups. BREAKING CHANGE: Filter on Linux no longer returns store.ErrCredentialNotFound when nothing matches; callers checking for that error on empty filter results must handle an empty map instead. Add fake-driven regression tests for the empty-collection and no-pattern-match cases. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Benehiko
force-pushed
the
fix/linux-filter-empty
branch
from
August 3, 2026 12:03
a9f1b9e to
8f21b34
Compare
Benehiko
marked this pull request as ready for review
August 3, 2026 12:03
docker-agent
reviewed
Aug 3, 2026
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
The PR removes two early-return guards in keychain_linux.go that incorrectly returned store.ErrCredentialNotFound when Filter found no matching items — aligning the Linux Secret Service backend with the empty-result contract already followed by the macOS and Windows backends. A clarifying godoc comment is added to store/store.go to make this contract explicit.
All added lines are documentation comments or test assertions. No new logic paths are introduced; only error-returning paths are removed. No resource leaks, nil dereferences, or logic errors were found in the changed code.
joe0BAB
approved these changes
Aug 3, 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.
What
The Linux Secret Service backend's
Filterreturnedstore.ErrCredentialNotFoundwhen nothing matched — both when the collection search returned no items and when items existed but none survived pattern matching. The macOS and Windows backends return an empty map with a nil error in the same situation.This removes both empty-as-error guards from the Linux
Filter, following the same rationale as 4a163cd, which alignedGetAllMetadatain the same way.Why
The
store.Store.Filtergodoc never specified what an empty result means, which is what allowed the platforms to diverge in the first place. This PR makes the contract explicit: a pattern matching nothing is a valid empty result, not a miss.ErrCredentialNotFoundstays reserved for single-item lookups (Get/Delete).Note: the only current caller (
plugins/passGetSecrets) maps an empty result toplugin.ErrNotFounditself, so end-to-end behavior through that path is unchanged. The fix matters for cross-platform consistency and future callers ofFilter.Testing
make keychain-linux-unit-testsbake matrix passes (Fedora 43 + Ubuntu 24, gnome-keyring).golangci-lint fmtandrunclean.Fixes #579
🤖 Generated with Claude Code