Skip to content

fix(bedrock,vertex): map 413/529 to typed exceptions, matching canonical client#1544

Open
Zawwarsami16 wants to merge 1 commit into
anthropics:mainfrom
Zawwarsami16:fix/bedrock-vertex-status-error-parity
Open

fix(bedrock,vertex): map 413/529 to typed exceptions, matching canonical client#1544
Zawwarsami16 wants to merge 1 commit into
anthropics:mainfrom
Zawwarsami16:fix/bedrock-vertex-status-error-parity

Conversation

@Zawwarsami16
Copy link
Copy Markdown

What's happening

The Bedrock and Vertex clients' _make_status_error methods are missing two status codes that the canonical Anthropic / AsyncAnthropic clients already map (and that the newer Mantle client also maps):

  • 413RequestTooLargeError
  • 529OverloadedError

So for users running on Bedrock or Vertex:

  • A 413 from the upstream API comes back as a generic APIStatusError — no RequestTooLargeError handler ever fires.
  • A 529 "Overloaded" falls into the >= 500 branch as InternalServerError — so retry / backoff code that keys off OverloadedError is silently broken on these platforms.

This is purely a drift bug — the canonical client added both mappings ages ago and the platform-specific clients didn't get the same update.

Comparison

Code _client.py lib/bedrock/_client.py (before) lib/vertex/_client.py (before) lib/bedrock/_mantle.py
400
401
403
404
409
413
422
429
503
504
529
≥500

Bold cells are what this PR adds.

What this PR does

Adds the missing 413 and 529 mappings to both lib/bedrock/_client.py and lib/vertex/_client.py. The Bedrock-specific 503 and Vertex-specific 503/504 mappings are preserved — those are real platform-frontend statuses and removing them would be a breaking change for users who catch them specifically.

Tests

Modeled on the existing test_make_status_error_sync_async_parity in tests/test_client.py, this PR adds parametrized tests that pin the full status-code mapping for both platforms — both sync and async variants:

  • tests/lib/test_bedrock.py::test_bedrock_make_status_error_maps_codes_to_typed_exceptions — 11 status codes
  • tests/lib/test_vertex.py::test_vertex_make_status_error_maps_codes_to_typed_exceptions — 12 status codes
$ uv run pytest tests/lib/test_bedrock.py tests/lib/test_vertex.py -k make_status_error
======================= 23 passed, 34 deselected in 0.21s ======================

The parametrized form will fail loudly the next time someone forgets to add a mapping in just one of the three places.

…cal client

The Bedrock and Vertex clients' `_make_status_error` methods were
missing two status codes that the canonical `Anthropic` / `AsyncAnthropic`
clients (and the newer Mantle client) already map:

- 413 → `RequestTooLargeError`
- 529 → `OverloadedError`

For users running on Bedrock or Vertex, a 413 from the upstream API
came back as the generic `APIStatusError` (no `RequestTooLargeError`
handler ever fired), and a 529 "Overloaded" landed in the `>= 500`
fall-through as `InternalServerError` — so retry/backoff code that
keys off `OverloadedError` was silently broken on these platforms.

Both 503 (Bedrock + Vertex) and 504 (Vertex only) are preserved.

Adds parametrized parity tests covering every typed status code on
both clients (11 cases on Bedrock, 12 on Vertex), modeled on the
existing `test_make_status_error_sync_async_parity` in
`tests/test_client.py`. All 23 new tests pass on both sync and async
variants.
@Zawwarsami16 Zawwarsami16 requested a review from a team as a code owner May 14, 2026 08:06
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