fix(oauth-health): skip alert when credentials file absent (keychain auth)#40
Open
drewdemann wants to merge 1 commit intoearlyaidopters:mainfrom
Open
fix(oauth-health): skip alert when credentials file absent (keychain auth)#40drewdemann wants to merge 1 commit intoearlyaidopters:mainfrom
drewdemann wants to merge 1 commit intoearlyaidopters:mainfrom
Conversation
On modern macOS, the Claude CLI stores OAuth credentials in Keychain instead of ~/.claude/.credentials.json. The OAuth health check currently treats a missing file the same as a malformed one and repeatedly alerts the user via Telegram, even though the spawned Claude subprocess authenticates successfully via the CLI's own Keychain lookup. Distinguish three read outcomes: - File missing (ENOENT): log debug and skip. Keychain auth is valid. - File exists but unreadable or invalid JSON: alert (unchanged). - File parsed but missing expiresAt: alert (unchanged). Expiry and expiring-soon alerts are unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
On modern macOS, the Claude CLI stores OAuth credentials in Keychain instead of
~/.claude/.credentials.json. The current OAuth health check treats a missing credentials file the same as a malformed one and repeatedly alerts the user via Telegram, even though the spawned Claude subprocess authenticates successfully via the CLI's own Keychain lookup.Change
Distinguish three read outcomes in
src/oauth-health.ts:expiresAt→ alert (unchanged behavior).Expiry and expiring-soon alerts behave identically to before.
Motivation
I set up ClaudeClaw on a Mac where
claudeauth lives in Keychain (no~/.claude/.credentials.jsonever existed on disk). The bot otherwise worked perfectly — spawned Claude subprocesses authenticated and responded — but the health check fired every 30 minutes with "Cannot read OAuth token. File missing or invalid structure." False positives that drowned out the signal when a real expiry alert eventually matters.Test plan
npm run buildpasses.No changes to the public API of
initOAuthHealthCheck,OAUTH_CHECK_MINUTES, orOAUTH_ALERT_HOURS.Happy to adjust the log message or wording if you have preferences.
🤖 Generated with Claude Code