Skip to content

fix: distinguish credential backend failures from missing credentials#233

Draft
bukinoshita wants to merge 1 commit intomainfrom
fix/credential-backend-error-handling-491e
Draft

fix: distinguish credential backend failures from missing credentials#233
bukinoshita wants to merge 1 commit intomainfrom
fix/credential-backend-error-handling-491e

Conversation

@bukinoshita
Copy link
Copy Markdown
Member

@bukinoshita bukinoshita commented Apr 9, 2026

Summary by cubic

Fixes misleading “No API key found” by distinguishing credential backend outages from missing credentials on Linux and Windows. Addresses BU-630 and aligns behavior with macOS.

  • Bug Fixes
    • Linux backend: return null only for exit codes 0/1; throw with details for other codes.
    • Windows backend: use exit code 44 for “Element not found”; throw on other failures with stderr.
    • resolveApiKeyAsync(): propagate backend errors as “Credential backend unavailable” instead of falling back to file.
    • CLI: requireClient() now emits credential_store_error; doctor reports backend unavailability and skips validation when down.
    • Tests: added Linux backend cases and a config test for error propagation.

Written for commit 11c3805. Summary will update on new commits.

Linux and Windows secure-storage backends collapsed all lookup failures
into null, causing resolveApiKeyAsync() to misreport backend outages as
'No API key found' instead of a storage-specific error.

Changes:
- linux.ts: exit codes 0/1 mean daemon responded (return null if no
  output), all other codes throw with backend-specific error message
- windows.ts: use exit code 44 for 'Element not found' (credential
  absent), throw on all other failures with error details
- config.ts: wrap backend.get() in try/catch, propagate backend errors
  as 'Credential backend unavailable' instead of silently falling through
- client.ts: use 'credential_store_error' code for backend failures
  instead of generic 'auth_error'
- doctor.ts: catch backend errors in API key checks, report storage
  backend unavailability instead of misleading 'No API key found'
- Add tests for Linux backend error handling and resolveApiKeyAsync
  backend error propagation

Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
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