Skip to content

fix(bedrock/aws/vertex): raise CredentialsError when credentials missing (#2038) - #2039

Open
mangeshraut712 wants to merge 6 commits into
anthropics:mainfrom
mangeshraut712:fix/bedrock-credentials-error
Open

mangeshraut712 wants to merge 6 commits into
anthropics:mainfrom
mangeshraut712:fix/bedrock-credentials-error

Conversation

@mangeshraut712

Copy link
Copy Markdown

Summary

When Bedrock/AWS session credentials or a Vertex API token cannot be resolved, the clients raised a bare RuntimeError. That is not an anthropic.AnthropicError, so callers (and frameworks wrapping the SDK) could not classify a missing-credentials configuration failure.

Raise the existing CredentialsError instead, keeping the previous message text.

Test plan

  • tests/lib/test_aws_auth.py::TestGetAuthHeaders::test_raises_on_missing_credentials now expects CredentialsError
  • Added tests/lib/test_bedrock_auth.py covering the Bedrock auth path

Fixes #2038

Replace bare RuntimeError with anthropic.CredentialsError (an
AnthropicError subclass) when AWS session credentials or a Vertex API
token cannot be resolved, so callers can catch configuration failures
with except AnthropicError.

Keeps the previous message text. Fixes anthropics#2038.
@mangeshraut712
mangeshraut712 requested a review from a team as a code owner October 27, 2026 07:19
mangeshraut712 and others added 5 commits November 2, 2026 12:45
Exercise Vertex tokenless refresh and Bedrock missing credentials for sync and async stable and beta message requests. Assert CredentialsError, preserve exact messages, and block provider HTTP. Replace the private Bedrock helper regression with public request-path tests.
Resolve import conflicts in vertex client and bedrock/vertex tests while
keeping CredentialsError for missing-credentials coverage.
…rror

# Conflicts:
#	src/anthropic/lib/bedrock/_auth.py
@mangeshraut712

Copy link
Copy Markdown
Author

Could a maintainer authorize the pending workflows for current head 299e296e7dc075689aab733a858b1e6168a7bf87? CI reports action_required, so hosted validation has not run. Please let me know if any contributor-side changes are needed before authorization or review.

This branch has not been deployed

No deployments
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.

AnthropicBedrock raises a bare RuntimeError when no AWS credentials resolve, instead of an anthropic error class (e.g. CredentialsError)

1 participant