Skip to content

feat: install Anthropic error response formatter for proxy failures - #846

Open
skamenan7 wants to merge 7 commits into
praxis-proxy:mainfrom
skamenan7:feat/J-6941-anthropic-error-formatter
Open

feat: install Anthropic error response formatter for proxy failures#846
skamenan7 wants to merge 7 commits into
praxis-proxy:mainfrom
skamenan7:feat/J-6941-anthropic-error-formatter

Conversation

@skamenan7

Copy link
Copy Markdown
Contributor

Summary

Installs the AnthropicErrorFormatter on requests positively classified as Anthropic Messages API formats (/v1/messages). When a fatal proxy failure occurs (e.g., upstream connection refused, timeout, or overload), this ensures downstream clients receive a standard Anthropic-compatible {"type":"error","error":{"type":...},"request_id":...} JSON envelope rather than a default proxy error response.

This covers the formatter installation, status code mapping, Unicode handling, fallback request ID generation, and comprehensive unit and integration testing.

Related issue

Closes #683

Validation

  • Unit tests (cargo test -p praxis-ai-apis -- anthropic)
  • Integration tests (cargo test -p praxis-tests-integration --test suite -- anthropic_messages)
  • make lint

Checklist

  • I reviewed every changed line and can explain the change.
  • New capabilities include an example config and functional example test.
  • User-facing behavior and generated documentation are updated.
  • Performance-sensitive changes include appropriate benchmark or load-test evidence.
  • Commits are signed and include a Signed-off-by trailer.

Breaking changes

None.

@skamenan7
skamenan7 requested a review from leseb August 31, 2026 22:33
@skamenan7
skamenan7 force-pushed the feat/J-6941-anthropic-error-formatter branch from a611d6a to baf0db7 Compare August 31, 2026 22:40
… proxy failures

Add an ErrorResponseFormatter implementation that produces the standard
Anthropic error envelope when Praxis synthesizes a fatal proxy response
(connection refusal, timeout, etc.).

The formatter is installed as a request extension after positive
Anthropic Messages classification. Praxis invokes it from fail_to_proxy
instead of emitting RFC 9457 Problem Details.

Mapping:
- 504 → timeout_error
- 529 → overloaded_error
- 429 → rate_limit_error
- other → api_error
- Top-level type is always "error"
- request_id captured from x-request-id header or generated
- Content-Type: application/json

Known gap: FormattedErrorResponse in praxis-filter 0.5.3 carries only
body + content_type. The matching request-id response header cannot be
set until Praxis extends the contract. The request ID is included in
the JSON body only. See Seb's confirmation in AI praxis-proxy#683.

Non-Anthropic classifications do not install the formatter.

Closes: RHAIENG-6941
Ref: praxis-proxy#683
Signed-off-by: Sumanth Kamenani <skamenan@redhat.com>
Signed-off-by: Sumanth Kamenani <skamenan@redhat.com>
… integration tests

Signed-off-by: Sumanth Kamenani <skamenan@redhat.com>
@skamenan7
skamenan7 force-pushed the feat/J-6941-anthropic-error-formatter branch from baf0db7 to 8097933 Compare August 31, 2026 23:00
@skamenan7
skamenan7 marked this pull request as ready for review September 1, 2026 13:43
@skamenan7
skamenan7 requested a review from a team September 1, 2026 13:43
@leseb

leseb commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Can we get a demo test like you did for the OpenAI one? Thanks

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.

feat(anthropic): format fatal proxy failures with Anthropic error envelopes

2 participants