Decode hex-encoded Claude Code Keychain credentials - #1
Merged
Conversation
Claude Code 2.1.x stores the Keychain item as hex JSON. Parsing it as UTF-8 JSON failed and skipped ~/.claude/.credentials.json, so usage limits reported unauthenticated while the CLI was logged in.
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.
Human comments
What was wrong
Claude Code 2.1.x stores the macOS Keychain item
Claude Code-credentialsas hex-encoded JSON (7b…is{). bb parsed that blob as UTF-8 JSON, failed, and treated a non-empty Keychain read as success, so it never opened~/.claude/.credentials.json. Settings → Usage limits then showed Claude asunauthenticatedwith empty windows even though the CLI was logged in.This is base bb (
plugins/provider-claude-code), not the community Usage plugin. The plugin only rendersGET /api/v1/system/usage-limits.Related: get-bb/bb#2928.
What changed
decodeCredentialBlobhex-decodes, then JSON-parses.HOST_DAEMON_PROTOCOL_VERSIONbump.Why this way
The empty-windows symptom looked like a User-Agent or
weekly_scopedparser bug. The actual failure was earlier: we never sent a token. Decode-then-file-fallback is the smallest change that makes an already-valid login visible.UA / percent / camelCase window keys / model-scoped caps (Fable) are a separate parser change in the same file. They stay out of this PR so a credentials bug is not mixed with a response-mapping change.
Benefit to bb
Every Mac user on Claude Code 2.1.x. Usage limits (and any
provider.usageclient) show the same session/weekly windows the CLI shows. No daemon update.Harvest
Independent. Already opened: get-bb/bb#2931 Fixes get-bb#2928.
Decision record: docs/perf-control-plane.md (PR #9).
How you verified
plugins/provider-claude-code/src/bridge/provider-maintenance.test.tscovers a hex Keychain blob and the file fallback after a non-JSON Keychain read.Related: get-bb#2928, get-bb#2931