Skip to content

fix(keychain)!: return empty map from Filter on Linux when nothing matches - #605

Merged
Benehiko merged 1 commit into
mainfrom
fix/linux-filter-empty
Aug 3, 2026
Merged

fix(keychain)!: return empty map from Filter on Linux when nothing matches#605
Benehiko merged 1 commit into
mainfrom
fix/linux-filter-empty

Conversation

@Benehiko

@Benehiko Benehiko commented Aug 3, 2026

Copy link
Copy Markdown
Member

What

The Linux Secret Service backend's Filter returned store.ErrCredentialNotFound when 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 aligned GetAllMetadata in the same way.

Why

The store.Store.Filter godoc 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. ErrCredentialNotFound stays reserved for single-item lookups (Get/Delete).

Note: the only current caller (plugins/pass GetSecrets) maps an empty result to plugin.ErrNotFound itself, so end-to-end behavior through that path is unchanged. The fix matters for cross-platform consistency and future callers of Filter.

Testing

  • Fake-driven regression tests: empty collection, and items present but no pattern match (asserting the secret is never loaded).
  • Full make keychain-linux-unit-tests bake matrix passes (Fedora 43 + Ubuntu 24, gnome-keyring).
  • golangci-lint fmt and run clean.

Fixes #579

🤖 Generated with Claude Code

…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
Benehiko force-pushed the fix/linux-filter-empty branch from a9f1b9e to 8f21b34 Compare August 3, 2026 12:03
@Benehiko Benehiko changed the title fix(keychain): return empty map from Filter on Linux when nothing matches fix(keychain)!: return empty map from Filter on Linux when nothing matches Aug 3, 2026
@Benehiko
Benehiko requested a review from joe0BAB August 3, 2026 12:03
@Benehiko
Benehiko marked this pull request as ready for review August 3, 2026 12:03

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Benehiko
Benehiko merged commit b22a9cb into main Aug 3, 2026
26 of 27 checks passed
@Benehiko
Benehiko deleted the fix/linux-filter-empty branch August 3, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

keychain: Linux Filter returns ErrCredentialNotFound on empty/no-match while macOS & Windows return an empty map

3 participants