fix(bedrock,vertex): map 413/529 to typed exceptions, matching canonical client
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):
- 413 →
RequestTooLargeError - 529 →
OverloadedError
So for users running on Bedrock or Vertex:
- A
413from the upstream API comes back as a genericAPIStatusError— noRequestTooLargeErrorhandler ever fires. - A
529"Overloaded" falls into the>= 500branch asInternalServerError— so retry / backoff code that keys offOverloadedErroris 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 codestests/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.