Repository navigation
Description
Problem
A Claude chat call that the gateway or Anthropic answers with an HTTP error loses the status of the reply. The call goes through the shared client of LLMClient, which has the retry transport. That transport raises httpx2.HTTPStatusError for a 4xx or 5xx reply after its last try. The Anthropic SDK catches that exception as a connection error, and _map_anthropic_errors in src/devops_cli/ai/client/claude.py builds an AIClientError with no status, so the reason reads LLM_INFERENCE_ERROR and not LLM_INFERENCE_ERROR, HTTP 529.
Seen on origin/main 27c7019 with uv run pytest tests/ai/client/test_ai_client_error_reason.py::test_a_claude_reply_with_a_status_gives_the_status after the test used the web fake: (None, 'LLM_INFERENCE_ERROR') was returned in place of (529, 'LLM_INFERENCE_ERROR, HTTP 529'). The test passed before because it gave the client a plain transport with no retries.
Expected
AIClientError.status and reason carry the HTTP status of the last reply, for Claude as for the other providers.
Acceptance criteria
- A test of the Claude call over the
webfake and the shared client (with its retry transport) answers 529 and checksstatus == 529andreason == "LLM_INFERENCE_ERROR, HTTP 529". - The Claude path reads the status from the
HTTPStatusErrorthat the retry transport raised.
Existing tool considered
Not applicable. The fix reads an exception the code already receives.
Related
Found while moving the AI tests to the HTTP entry point (#3791, #3758).
Proposed design
Problem statement
A Claude chat call that the gateway or Anthropic answers with an HTTP error loses the HTTP status after the shared retry transport raises httpx2.HTTPStatusError. The Anthropic SDK reports that error as a connection error. The _map_anthropic_errors function then builds an AIClientError with no status, so the reason reads LLM_INFERENCE_ERROR and not LLM_INFERENCE_ERROR, HTTP 529.
Acceptance criteria
Requirement: Claude status from the retry transport
The Claude error path SHALL set AIClientError.status from the HTTP status of the last reply when the shared retry transport raises httpx2.HTTPStatusError.
Scenario: Claude reply with status 529
- WHEN The web fake answers a Claude call with HTTP 529 and the client uses the shared client with its retry transport.
- THEN The raised AIClientError has status == 529 and reason == "LLM_INFERENCE_ERROR, HTTP 529".
Requirement: Status lookup through the cause chain
The Claude error mapping MUST inspect the cause chain of an anthropic.APIConnectionError for httpx2.HTTPStatusError before it builds a connection error.
Scenario: Connection error wraps a status error
- WHEN An anthropic.APIConnectionError wraps an httpx2.HTTPStatusError whose response status is 529.
- THEN The mapper raises an AIClientError with status == 529 and not a status-less connection error.
Requirement: Connection error without a status stays status-less
The Claude error mapping SHALL leave AIClientError.status as None when the cause chain holds no httpx2.HTTPStatusError.
Scenario: Plain connection failure
- WHEN An anthropic.APIConnectionError has no httpx2.HTTPStatusError in its cause chain.
- THEN The raised AIClientError has status None.
Existing Tool Considered
No alternatives check has run. The body marks the existing-tool question not applicable because the fix reads an exception that the code already receives. No open, maintained tool or library covers this internal exception mapping. The project builds the fix itself: about 3,000 tokens to change, test and keep the code, and about 30 minutes of elapsed time.
Key questions
- Which exception does the shared retry transport raise after its last try?: The shared retry transport raises httpx2.HTTPStatusError for a 4xx or 5xx reply after its last try. [sources: src/devops_cli/ai/retries/init.py, tests/ai/client/test_ai_client_retries.py]
- Why does the Claude path lose the HTTP status?: The Anthropic SDK reports the retry transport's httpx2.HTTPStatusError as an anthropic.APIConnectionError. The _map_anthropic_errors function handles that connection error before its anthropic.APIStatusError branch, and _connection_error builds an AIClientError with no status. [sources: src/devops_cli/ai/client/claude.py, src/devops_cli/ai/client/base.py]
- How should the Claude path build the status-bearing error?: Find the httpx2.HTTPStatusError in the cause chain of the anthropic.APIConnectionError and pass it to _provider_http_error. That method already turns an HTTP status error into an AIClientError with status and masked detail. (best practice) [sources: src/devops_cli/ai/client/claude.py, src/devops_cli/ai/client/base.py, src/devops_cli/ai/retries/init.py]
- Chosen: Reuse _provider_http_error with the cause HTTPStatusError. The shared path already sets status and masked detail for an HTTP status error.
- Rejected: Build AIClientError directly in _map_anthropic_errors. This duplicates status and detail handling and can drift from the shared path.
- Rejected: Read the status from the exception message. The message is not a stable contract and may be masked.
- Where should the cause-chain lookup live?: Add a small private helper in claude.py and call it from the anthropic.APIConnectionError branch of _map_anthropic_errors. (best practice) [sources: src/devops_cli/ai/client/claude.py, src/devops_cli/ai/client/base.py]
- Chosen: Private helper in claude.py. The lookup is Claude-specific and keeps the shared base class unchanged.
- Rejected: Helper in BaseLLMProviderMixin. No other provider needs to unwrap an SDK connection error for an HTTP status.
- Rejected: Inline code in the except block. A helper makes the cause-chain walk testable and avoids repeated code.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-08: none.
Tool: none found.
Activity
dan-petty commentedon Nov 6, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(ai)scope of the title gives the scope.The bug hides the HTTP status in error reports, which slows diagnosis but does not break the call.Accurate error reasons let operators act on a Claude 529 or 429 without reading raw logs.The fix reads a field from an exception the code already catches, in one function.Both items lose HTTP error context in the reason string, but #2794 is about Ollama and the gateway log while the candidate is about Claude and the retry transport exception.devops-cli-service commentedon Nov 7, 2026
Status set to Ready at 8436734 (see proposed design in issue body).
devops-cli-service commentedon Nov 8, 2026
Alternatives check: none
Reason: The searches for a library that preserves the HTTP status when an Anthropic SDK connection error wraps an httpx HTTPStatusError returned only unrelated reference pages (MDN error and HTTP-status docs), so no open, maintained tool or library covers the need. The fix is an internal change to the project's own exception mapping in
claude.py, which the issue itself marks as not applicable.Tool: none found
Lacks:
_map_anthropic_errors/_provider_http_errorcode pathSearches run:
Checked on 2026-11-08. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 12, 2026
Released in v0.118.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.118.0
devops-cli-service commentedon Nov 12, 2026
Live since 2026-11-12 12:40 UTC