Skip to content

fix(assistant): surface Claude gateway authentication failures - #1270

Open
DivyamTalwar wants to merge 1 commit into
Tencent:mainfrom
DivyamTalwar:fix/claude-report-terminal-auth-failure
Open

DivyamTalwar wants to merge 1 commit into
Tencent:mainfrom
DivyamTalwar:fix/claude-report-terminal-auth-failure

Conversation

@DivyamTalwar

Copy link
Copy Markdown

What changed

Refs #1130.

Claude Code 2.1.329 emits an API-error assistant event and a failed result with api_error_status: 401 when a gateway rejects its credentials. The existing parser ignored both structured statuses. Because the CLI also exits nonzero, the workspace turn was reported as CLI_EXIT_NONZERO and could show the unrelated unrecognized_model stderr warning.

The assistant now recognizes structured 401 and 403 status on CLI API-error events, including a failed result with a nonempty error message. The existing credential failure path shows the actionable authentication error, and runner-login failures keep their existing login guidance. Successful replies and ordinary model content keep their existing handling.

This addresses the error reporting part of #1130. Gateway authentication header configuration is tracked separately in #897.

Scope

  • Platform core / API / runner

Compatibility

No API response fields, stored data, or provider credential configuration change. A rejected credential now receives the existing AUTHENTICATION_FAILED classification.

Validation

  • Ran Claude Code 2.1.329 against a loopback-only Anthropic Messages fixture returning HTTP 401 to capture the actual terminal event shape.
  • Reproduced the generic exit classification with the new tests on upstream. The structured 401 and 403 regression tests and the existing terminal-error and Claude reply recovery tests pass with this patch.
  • go vet -p=2 ./internal/httpapi, git diff --check, python3 scripts/check-public.py, and Gitleaks 8.30.1 on candidate tracked files passed.
  • The full Go suite and browser acceptance were not run for this branch.

Safety

  • No credentials, internal endpoints, production data, or organization-specific infrastructure.
  • Existing files and unrelated changes preserved.

Codex assisted with the code and tests. I verified the protocol using the installed CLI and confirmed the regression fails on upstream and passes with the patch.

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