fix(bedrock): pass aws_profile to boto3.Session in _infer_region#1521
Open
nileshpatil6 wants to merge 1 commit intoanthropics:mainfrom
Open
fix(bedrock): pass aws_profile to boto3.Session in _infer_region#1521nileshpatil6 wants to merge 1 commit intoanthropics:mainfrom
nileshpatil6 wants to merge 1 commit intoanthropics:mainfrom
Conversation
When a user specifies aws_profile, _infer_region() was creating a boto3.Session() without profile_name, so the profile's configured region was silently ignored and the client fell back to AWS_REGION env var or us-east-1. Fix: accept aws_profile as an optional parameter and forward it to boto3.Session(profile_name=aws_profile). Update both AnthropicBedrock and AsyncAnthropicBedrock call sites accordingly. Fixes 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.
Problem
When a user passes
aws_profiletoAnthropicBedrockorAsyncAnthropicBedrockwithout an explicitaws_region,_infer_region()is called to look up the region. However_infer_region()createsboto3.Session()with no arguments, so the named profile's configured region is silently ignored. The client then falls back toAWS_REGIONenv var or hard-codedus-east-1.Minimal reproduction:
Fixes #892.
Fix
Add
aws_profile: str | None = Noneto_infer_region()and forward it toboto3.Session(profile_name=aws_profile). Update bothAnthropicBedrock.__init__andAsyncAnthropicBedrock.__init__call sites from_infer_region()to_infer_region(aws_profile).The change is backward-compatible: when
aws_profileisNone(the default),boto3.Session(profile_name=None)behaves identically toboto3.Session().