fix(bedrock): pass aws_profile to _infer_region() for correct region detection#1635
Open
Oxygen56 wants to merge 1 commit into
Open
fix(bedrock): pass aws_profile to _infer_region() for correct region detection#1635Oxygen56 wants to merge 1 commit into
Oxygen56 wants to merge 1 commit into
Conversation
…detection When aws_profile is specified in AnthropicBedrock or AnthropicBedrockClient but AWS_REGION is not set, _infer_region() previously created a boto3.Session() without profile_name, defaulting to the 'default' profile and ignoring the caller's explicitly configured profile. This caused cross-region inference failures for users with non-default AWS profiles. Fix: accept an optional aws_profile parameter in _infer_region() and pass it through to boto3.Session(profile_name=aws_profile). Closes anthropics#892.
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.
Summary
When
aws_profileis specified inAnthropicBedrockorAnthropicBedrockClientbutAWS_REGIONis not set,_infer_region()previously created aboto3.Session()withoutprofile_name, defaulting to the 'default' profile and ignoring the caller's explicitly configured profile. This caused cross-region inference failures (HTTP 403) for users with non-default AWS profiles.Root cause
_infer_region()calledboto3.Session()with no arguments, which uses the default profile regardless of whataws_profilethe caller specified. The user's profile might haveregion = us-west-2configured, but_infer_regionwould still returnus-east-1.Fix
aws_profileparameter in_infer_region()boto3.Session(profile_name=aws_profile)AnthropicBedrockandAnthropicBedrockClient) to passaws_profileTest plan
The fix matches the verified solution from the issue thread (multiple users confirmed it works).
Before:
After:
Closes #892.