fix(bedrock,vertex): add missing 413 and 529 status error handling#1306
Open
4444J99 wants to merge 1 commit intoanthropics:mainfrom
Open
fix(bedrock,vertex): add missing 413 and 529 status error handling#13064444J99 wants to merge 1 commit intoanthropics:mainfrom
4444J99 wants to merge 1 commit intoanthropics:mainfrom
Conversation
The Bedrock and Vertex clients' _make_status_error methods were missing handlers for HTTP 413 (RequestTooLargeError) and 529 (OverloadedError). These were already handled in the main Anthropic/AsyncAnthropic clients (added in anthropics#1244), but the Bedrock and Vertex variants fell through to the generic InternalServerError (for 529) or APIStatusError (for 413). This makes error handling consistent across all client variants, so users can catch specific exception types regardless of which provider they use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
BaseBedrockClientandBaseVertexClient_make_status_errormethods are missing handlers for HTTP 413 (RequestTooLargeError) and 529 (OverloadedError). These were added to the mainAnthropic/AsyncAnthropicclients in #1244, but the Bedrock and Vertex variants were not updated.Before this change:
AnthropicBedrockreceiving a 413 response returns a genericAPIStatusErrorinstead ofRequestTooLargeErrorAnthropicBedrockreceiving a 529 response returnsInternalServerErrorinstead ofOverloadedErrorAnthropicVertex(and their async counterparts)After this change:
All three client families (
Anthropic,AnthropicBedrock,AnthropicVertex) return the same typed exception for every status code.Changes
src/anthropic/lib/bedrock/_client.py— add 413 and 529 handlers toBaseBedrockClient._make_status_errorsrc/anthropic/lib/vertex/_client.py— add 413 and 529 handlers toBaseVertexClient._make_status_errortests/lib/test_bedrock.py— add parametrizedtest_make_status_errorcovering all 11 status codestests/lib/test_vertex.py— add parametrizedtest_make_status_errorcovering all 12 status codes (including Vertex-specific 504)Test plan
test_make_status_error_sync_async_parityintest_client.pycontinues to passlib/(hand-maintained)