Commit Graph
1 Commits
Author SHA1 Message Date
6cf8757dbe fix(server): report backend errors on the Anthropic messages bridge (#3006)
* fix(server): report backend errors on the Anthropic messages bridge

POST /v1/messages answered 200 with an empty text block whenever the
backend failed. convert_openai_chat_to_anthropic() has no error branch, so
the router's error payload fell into its empty-content path, and the
streaming adapter inspects only id, usage and choices[0], so it dropped the
framed error event the OpenAI stream carries since #2975.

Relay the failure instead: the non-streaming path answers with an Anthropic
error body and the backend's own status, and the streaming path emits an
event: error frame and ends the stream there.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PJEHxATjVbCwjcJesuFxTs

* fix(server): map backend status onto Anthropic error types consistently

Backends reported an upstream HTTP status under two different keys, and a
backend that returned its own structured error carried no status at all, so
the Anthropic bridge translated a 429 or 5xx as a generic 500/api_error.
The proxy now always publishes `status_code`, and the error-type mapping
covers every status Anthropic names.

* fix(server): add the billing, conflict and timeout Anthropic error types

Anthropic names a type for 402, 409 and 504. The first two fell through to
invalid_request_error and the third to api_error, so a backend that returned
one of them was reported to the client as a different class of failure.

* apply debian package cmake test fix

---------

Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: fl0rianr <[email protected]>
2026-08-09 23:47:15 +00:00