Skip to content

fix(posixage)!: return empty map from Filter and GetAllMetadata when nothing matches - #726

Merged
Benehiko merged 1 commit into
mainfrom
fix/posixage-empty-filter
Oct 30, 2026
Merged

Benehiko merged 1 commit into
mainfrom
fix/posixage-empty-filter

Conversation

@Benehiko

@Benehiko Benehiko commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

secrets.Store.Filter documents that a pattern matching nothing is a valid empty result: an empty (non-nil) map and a nil error, not ErrNotFound. Every backend follows that except posixage, which returns nil, secrets.ErrNotFound from both Filter and GetAllMetadata when nothing matches.

Backend Empty store Items exist, none match
keychain darwin empty map empty map
keychain linux empty map empty map
keychain windows empty map empty map
store/mocks, plugins/pass/teststore empty map empty map
posixage (before) ErrNotFound ErrNotFound
posixage (after) empty map empty map

The contract was added in 8f21b34, which aligned Filter on the Linux keychain, after 4a163cd did the same for GetAllMetadata. posixage was missed both times. This is not a regression from #725: before it, posixage returned store.ErrCredentialNotFound here, the same error value.

The change drops the two len(results) == 0 guards. results is already a non-nil map.

Breaking: callers that check errors.Is(err, secrets.ErrNotFound) (or store.ErrCredentialNotFound) after posixage Filter or GetAllMetadata must handle an empty map instead. Nothing in this repo does; posixage is only used by its own tests here.

Verification
  • Three new subtests in TestPOSIXAge: Filter on an empty store, Filter with no matching secret, GetAllMetadata on an empty store. All three fail without the fix (secret not found) and pass with it.
  • go test -race ./store/posixage/... passes on main after chore: lift x/secrets into a dependency-free secrets module #725.
  • go vet for darwin, linux and windows; golangci-lint on darwin: 0 issues.

Out of scope, noted for later: posixage Get on a missing ID returns the underlying file-system error rather than secrets.ErrNotFound, and Delete on a missing ID returns nil. So after this change posixage never returns ErrNotFound, unlike the keychain backends, which reserve it for single-item lookups.

AI disclosure: drafted with an AI coding agent (alki, Claude) under my direction; I reviewed the changes.

@Benehiko
Benehiko requested a review from a team as a code owner October 30, 2026 13:37

@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

@Benehiko
Benehiko force-pushed the chore/secrets-module branch from 8861c83 to eefca35 Compare October 30, 2026 13:42
@Benehiko
Benehiko force-pushed the fix/posixage-empty-filter branch from 8228129 to e9f45ce Compare October 30, 2026 13:49
@Benehiko
Benehiko force-pushed the chore/secrets-module branch from eefca35 to 2aaad38 Compare October 30, 2026 13:56
@Benehiko
Benehiko force-pushed the fix/posixage-empty-filter branch from e9f45ce to 30b9751 Compare October 30, 2026 13:57
Base automatically changed from chore/secrets-module to main October 30, 2026 14:28
…nothing matches

The posixage backend's Filter and GetAllMetadata returned secrets.ErrNotFound when no secret matched, both on an empty store and when secrets existed but none matched the pattern. The keychain backends on macOS, Linux and Windows and the mock stores return an empty (non-nil) map with a nil error in the same situation, as documented on secrets.Store.Filter. 8f21b34 and 4a163cd aligned the Linux keychain the same way; posixage was missed.

Drop both guards.

Add regression tests for Filter on an empty store, Filter with no matching secret, and GetAllMetadata on an empty store.

BREAKING CHANGE: posixage Filter and GetAllMetadata no longer return secrets.ErrNotFound (store.ErrCredentialNotFound) when nothing matches; callers checking for that error on empty results must handle an empty map instead.

Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
@Benehiko
Benehiko force-pushed the fix/posixage-empty-filter branch from 30b9751 to 749e998 Compare October 30, 2026 14:45
@Benehiko
Benehiko enabled auto-merge October 30, 2026 14:55
@Benehiko
Benehiko disabled auto-merge October 30, 2026 14:55
@Benehiko
Benehiko merged commit 3254757 into main Oct 30, 2026
23 checks passed
@Benehiko
Benehiko deleted the fix/posixage-empty-filter branch October 30, 2026 15:04
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.

3 participants