-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: improve Claude Code authentication error handling #8952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 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
Review SummaryI've reviewed the changes in this PR and identified the following issue: Issues to Address
|
| 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)) | ||
| } |
There was a problem hiding this comment.
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.
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:
claude loginTesting
Changes
src/i18n/locales/en/common.jsonsrc/api/providers/claude-code.tssrc/integrations/claude-code/run.tssrc/api/providers/__tests__/claude-code.spec.tsFixes #8946
Important
Improves authentication error handling in Claude Code CLI with better detection, user-friendly messages, and comprehensive pattern matching.
claude-code.tsandrun.ts.isAuthenticationError()function to detect patterns like '401', '403', 'unauthorized', etc.common.jsonwith user-friendly guidance for authentication failures.claude-code.spec.ts.runClaudeCode()inrun.tsto handle authentication errors in stderr or error output.authenticationErrormessage incommon.jsonfor i18n support.This description was created by
for 4204fc5. You can customize this summary. It will automatically update as commits are pushed.