Skip to content

fix(keychain): export ErrNoDefaultCollection sentinel#539

Merged
Benehiko merged 2 commits into
mainfrom
fix/export-no-default-collection
Jun 1, 2026
Merged

fix(keychain): export ErrNoDefaultCollection sentinel#539
Benehiko merged 2 commits into
mainfrom
fix/export-no-default-collection

Conversation

@Benehiko
Copy link
Copy Markdown
Member

@Benehiko Benehiko commented Jun 1, 2026

The errNoDefaultCollection sentinel was package-private, so callers outside the keychain package could not use errors.Is to distinguish "no keychain infrastructure available" from other I/O errors. This matters for headless Linux deployments where the condition is expected and routine, and where an orchestration layer wants to fall back gracefully rather than resort to fragile error message comparisons.

Export the sentinel as ErrNoDefaultCollection. It is declared in the cross-platform keychain.go (rather than the Linux-specific file) so that cross-platform callers can reference it on every platform, even though the condition is only ever produced on Linux.

The errNoDefaultCollection sentinel was package-private, so callers
outside the keychain package could not use errors.Is to distinguish
"no keychain infrastructure available" from other I/O errors. This
matters for headless Linux deployments where the condition is expected
and routine, and where an orchestration layer wants to fall back
gracefully rather than resort to fragile error message comparisons.

Export the sentinel as ErrNoDefaultCollection. It is declared in the
cross-platform keychain.go (rather than the Linux-specific file) so that
cross-platform callers can reference it on every platform, even though
the condition is only ever produced on Linux.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Benehiko Benehiko requested a review from joe0BAB June 1, 2026 08:02
Copy link
Copy Markdown

@docker-agent docker-agent Bot left a comment

Choose a reason for hiding this comment

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

Assessment: 🟢 APPROVE

This is a clean, well-scoped export of a package-private error sentinel. The change correctly:

  • Moves errNoDefaultCollection to the cross-platform keychain.go so callers on all platforms can reference it
  • Removes the Linux-only declaration and updates the single call site to use the exported name
  • Updates the test to use ErrNoDefaultCollection directly, verifying errors.Is compatibility

No bugs were found in the changed code. The errors.Is chain is intact (no wrapping), the sentinel propagates correctly through resolveDefaultCollection, and the test coverage for the new public API is appropriate.

Clarify in the doc comment that the condition is currently specific to
the Linux keyring (freedesktop Secret Service) and never returned on
macOS or Windows, which have no "default collection" concept. The
sentinel still lives in the cross-platform file so platform-agnostic
callers can reference it without build tags; on non-Linux platforms it
simply never matches.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Benehiko Benehiko merged commit c400dd0 into main Jun 1, 2026
18 checks passed
@Benehiko Benehiko deleted the fix/export-no-default-collection branch June 1, 2026 08:28
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.

2 participants