Skip to content

fix: refresh Claude auth status after login flow#617

Open
CoderLuii wants to merge 2 commits intositeboon:mainfrom
CoderLuii:fix/claude-auth-status-refresh
Open

fix: refresh Claude auth status after login flow#617
CoderLuii wants to merge 2 commits intositeboon:mainfrom
CoderLuii:fix/claude-auth-status-refresh

Conversation

@CoderLuii
Copy link
Copy Markdown

@CoderLuii CoderLuii commented Apr 4, 2026

Summary

  • re-check Claude auth state after the login flow completes instead of trusting the terminal exit code alone
  • return more actionable Claude auth status errors for unreadable, expired, or missing credentials

Testing

  • validated in HolyClaude integration flow while reproducing silent Claude auth failures from the web UI

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced authentication error handling to provide more specific and actionable error messages when credentials are missing, unreadable, or expired.
    • Improved the login completion process to reliably verify authentication status before confirming successful login, ensuring users receive accurate feedback on their authentication attempts.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 4, 2026

📝 Walkthrough

Walkthrough

Enhanced authentication error handling in the Claude credentials verification flow by adding granular error responses for missing/unreadable credential files, expired OAuth tokens, and explicit error messages. Updated the login completion handler to await auth status validation before marking login as successful, ensuring proper auth confirmation.

Changes

Cohort / File(s) Summary
Backend Credentials Validation
server/routes/cli-auth.js
Refactored checkClaudeCredentials() with improved error handling: checks for missing credentials file early (ENOENT), adds nested try/catch for JSON parsing with specific "unreadable credentials" error, distinguishes between expired tokens and missing tokens with targeted error messages.
Frontend Auth Status Management
src/components/settings/hooks/useSettingsController.ts
Modified checkAuthStatus to explicitly return Promise<AuthStatus>. Updated handleLoginComplete to await auth validation before setting success status; success is now only set when exit code is 0 and auth is confirmed, preventing premature success marking.

Possibly related issues

Possibly related PRs

Suggested reviewers

  • viper151
  • blackmammoth

Poem

🐰 Hop, skip, and validated!
Auth errors now clearly stated,
Credentials checked with care,
Tokens expired? We're aware!
Login's success sealed when truly gated! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: refresh Claude auth status after login flow' accurately summarizes the main change—improving authentication status validation after login by re-checking auth state instead of relying solely on exit codes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/settings/hooks/useSettingsController.ts`:
- Around line 744-746: The code currently only updates save status when exitCode
=== 0 which can mask a successful auth re-check; remove the exitCode gating in
the block around checkAuthStatus()/authStatus and always
setSaveStatus(authStatus.authenticated ? 'success' : 'error') based on the
result of checkAuthStatus(); locate the logic in useSettingsController.ts where
exitCode and authStatus are used and update the conditional that calls
setSaveStatus (and optionally log non-zero exitCode separately) so final login
outcome relies on authStatus.authenticated not exitCode.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f0cbe17f-1be2-4ea3-a8a4-be6e20007296

📥 Commits

Reviewing files that changed from the base of the PR and between 388134c and de515f7.

📒 Files selected for processing (2)
  • server/routes/cli-auth.js
  • src/components/settings/hooks/useSettingsController.ts

Comment on lines +744 to +746
if (exitCode === 0) {
setSaveStatus(authStatus.authenticated ? 'success' : 'error');
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Don’t gate final login outcome on process exit code after auth re-check.

At Line 744, requiring exitCode === 0 can hide a valid login when checkAuthStatus() confirms authentication, and non-zero exits skip setting an explicit error state.

Suggested fix
-      if (exitCode === 0) {
-        setSaveStatus(authStatus.authenticated ? 'success' : 'error');
-      }
+      setSaveStatus(authStatus.authenticated ? 'success' : 'error');
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (exitCode === 0) {
setSaveStatus(authStatus.authenticated ? 'success' : 'error');
}
setSaveStatus(authStatus.authenticated ? 'success' : 'error');
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/settings/hooks/useSettingsController.ts` around lines 744 -
746, The code currently only updates save status when exitCode === 0 which can
mask a successful auth re-check; remove the exitCode gating in the block around
checkAuthStatus()/authStatus and always setSaveStatus(authStatus.authenticated ?
'success' : 'error') based on the result of checkAuthStatus(); locate the logic
in useSettingsController.ts where exitCode and authStatus are used and update
the conditional that calls setSaveStatus (and optionally log non-zero exitCode
separately) so final login outcome relies on authStatus.authenticated not
exitCode.

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.

1 participant