Skip to content

Decode hex-encoded Claude Code Keychain credentials - #1

Merged
Guitaraholic merged 1 commit into
mainfrom
fix/claude-keychain-hex-json
Sep 2, 2026
Merged

Decode hex-encoded Claude Code Keychain credentials#1
Guitaraholic merged 1 commit into
mainfrom
fix/claude-keychain-hex-json

Conversation

@Guitaraholic

@Guitaraholic Guitaraholic commented Sep 2, 2026

Copy link
Copy Markdown

Human comments

What was wrong

Claude Code 2.1.x stores the macOS Keychain item Claude Code-credentials as 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 as unauthenticated with 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 renders GET /api/v1/system/usage-limits.

Related: get-bb/bb#2928.

What changed

  • decodeCredentialBlob hex-decodes, then JSON-parses.
  • If Keychain still does not yield credentials, fall back to the file.
  • Wire shape is unchanged. No HOST_DAEMON_PROTOCOL_VERSION bump.

Why this way

The empty-windows symptom looked like a User-Agent or weekly_scoped parser 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.usage client) 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.ts covers a hex Keychain blob and the file fallback after a non-JSON Keychain read.

Related: get-bb#2928, get-bb#2931

AGENT GENERATED

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.
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.

Claude Code usage limits report unauthenticated: macOS Keychain blob is hex JSON

1 participant