Repository navigation
Python: Prefer boto3 session and injected client region over BEDROCK_REGION - #9967
Open
Mehedi Hasan (Mahdi-Hasan) wants to merge 2 commits into
Open
Mehedi Hasan (Mahdi-Hasan) wants to merge 2 commits into
Mehedi Hasan (Mahdi-Hasan) wants to merge 2 commits into
Conversation
…REGION BedrockChatClient and BedrockEmbeddingClient resolved BEDROCK_REGION before the region of a caller-supplied boto3 session, so a session configured for another region was silently redirected. An injected runtime client also reported the ambient region instead of its own. Region now resolves as: injected client's region, explicit `region=`, boto3 session region, BEDROCK_REGION, then us-east-1. Fixes microsoft#9962 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mehedi Hasan (Mahdi-Hasan)
temporarily deployed
to
github-app-auth
November 2, 2026 11:18 — with
GitHub Actions
Inactive
Mehedi Hasan (Mahdi-Hasan)
had a problem deploying
to
github-app-auth
November 2, 2026 11:18 — with
GitHub Actions
Error
Author
|
@microsoft-github-policy-service agree |
Mehedi Hasan (Mahdi-Hasan)
marked this pull request as ready for review
November 2, 2026 11:22
Mehedi Hasan (Mahdi-Hasan)
temporarily deployed
to
github-app-auth
November 2, 2026 11:22 — with
GitHub Actions
Inactive
Mehedi Hasan (Mahdi-Hasan)
temporarily deployed
to
github-app-auth
November 2, 2026 11:24 — with
GitHub Actions
Inactive
This branch was previously deployed
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.
Motivation & Context
BedrockChatClientandBedrockEmbeddingClientreadBEDROCK_REGIONbefore the region of a caller-suppliedboto3_session. A session set toeu-west-1was sent tous-east-1when the env var said so, with no error. An injected runtime client also reported the ambient region inclient.regionandservice_url().Description & Review Guide
meta.region_name, explicitregion=,boto3_session.region_name,BEDROCK_REGION, thenus-east-1.region=still overrides the session, as the issue asks.regionargument.BEDROCK_REGIONto a different value now get the session's region. This is the fix the issue asks for. Callers who want the old result can passregion=.env-region-winstest cases encoded the old order. I replaced them withsession-region-beats-envand added anenv-regioncase for a session with no region.Related Issue
Fixes #9962
AI Assistance
AI assistance details: implementation, tests, and this description. The issue's repro was re-run against a real
boto3.Sessionbefore and after the change.Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.🤖 Generated with Claude Code