Skip to content

Conversation

@roomote
Copy link

@roomote roomote bot commented Oct 31, 2025

Description

This PR improves error handling for Claude Code CLI authentication failures, addressing Issue #8946 where users were unable to login to Claude Code CLI v2.0.30.

Problem

Users were experiencing authentication failures with Claude Code CLI v2.0.30 on Windows, receiving generic error messages that didn't provide clear guidance on how to resolve the issue.

Solution

This PR implements:

  • Better error detection: Added authentication error detection in both the Claude Code provider and integration layers
  • User-friendly error messages: Added dedicated i18n error message that provides clear steps for authentication
  • Comprehensive error pattern matching: Detects various authentication error patterns (401, 403, 'unauthorized', 'login required', etc.)
  • Helpful remediation guidance: Error message now instructs users to:
    1. Open a terminal/command prompt
    2. Run claude login
    3. Follow the authentication prompts
    4. Try again in VS Code

Testing

  • Added comprehensive test coverage for authentication error scenarios
  • All existing tests continue to pass
  • Verified error detection for multiple authentication failure patterns

Changes

  • Added authentication error message in src/i18n/locales/en/common.json
  • Enhanced error handling in src/api/providers/claude-code.ts
  • Added authentication error detection in src/integrations/claude-code/run.ts
  • Added tests in src/api/providers/__tests__/claude-code.spec.ts

Fixes #8946


Important

Improves authentication error handling in Claude Code CLI with better detection, user-friendly messages, and comprehensive pattern matching.

  • Error Handling:
    • Improved authentication error detection in claude-code.ts and run.ts.
    • Added isAuthenticationError() function to detect patterns like '401', '403', 'unauthorized', etc.
    • Enhanced error messages in common.json with user-friendly guidance for authentication failures.
  • Testing:
    • Added tests for authentication error scenarios in claude-code.spec.ts.
    • Verified detection of multiple authentication failure patterns.
  • Misc:
    • Updated runClaudeCode() in run.ts to handle authentication errors in stderr or error output.
    • Added authenticationError message in common.json for i18n support.

This description was created by Ellipsis for 4204fc5. You can customize this summary. It will automatically update as commits are pushed.

- Add dedicated authentication error message in i18n translations
- Detect authentication errors in Claude Code provider and run.ts
- Provide helpful instructions for users to authenticate with 'claude login'
- Add comprehensive tests for authentication error detection

Fixes #8946
@roomote roomote bot requested review from cte, jr and mrubens as code owners October 31, 2025 13:47
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 31, 2025
@roomote
Copy link
Author

roomote bot commented Oct 31, 2025

Review Summary

I've reviewed the changes in this PR and identified the following issue:

Issues to Address

  • Code duplication: The isAuthenticationError() function is duplicated in both src/api/providers/claude-code.ts and src/integrations/claude-code/run.ts with inconsistent pattern lists (10 patterns vs 12 patterns). Consider extracting this to a shared utility function to maintain consistency and reduce duplication.

Follow Along on Roo Code Cloud

@dosubot dosubot bot added the bug Something isn't working label Oct 31, 2025
Comment on lines +193 to +209
private isAuthenticationError(message: string): boolean {
const authErrorPatterns = [
"authentication failed",
"unauthorized",
"not authenticated",
"login required",
"invalid api key",
"api key expired",
"credential",
"auth error",
"403",
"401",
]

const lowerMessage = message.toLowerCase()
return authErrorPatterns.some((pattern) => lowerMessage.includes(pattern))
}
Copy link
Author

Choose a reason for hiding this comment

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

The isAuthenticationError() function is duplicated here and in src/integrations/claude-code/run.ts (lines 290-308) with inconsistent pattern lists. The run.ts version includes two additional patterns: "please authenticate" and "claude login". Consider extracting this to a shared utility function to maintain consistency and reduce duplication.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Oct 31, 2025
@daniel-lxs daniel-lxs closed this Oct 31, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Oct 31, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Oct 31, 2025
@daniel-lxs daniel-lxs deleted the fix/claude-code-auth-error-handling branch October 31, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] Can't login to Claude Code CLI

4 participants