fix(core): expand AWS_REGION in Bedrock Mantle base URL - #40076
Open
sergical wants to merge 1 commit into
Open
Conversation
The catalog advertises the Mantle endpoint as a template (https://bedrock-mantle.${AWS_REGION}.api.aws/openai/v1). On the v1 path the bedrock provider's vars() loader substitutes it, but the v2 plugin never did, so every openai.* Bedrock model requested that literal hostname and failed to connect. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one potentially related PR: Related PR:
This PR might be related because it also addresses Bedrock provider region handling. However, the titles and descriptions suggest they address different aspects: #35787 focuses on prompting users for region selection, while #40076 focuses on template variable substitution in the Mantle base URL. If #35787 is still open or was recently closed/merged, it would be worth reviewing to ensure the changes are compatible or don't conflict. |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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.
Issue for this PR
Closes #40075
Type of change
What does this PR do?
The catalog gives the Mantle endpoint as a template,
https://bedrock-mantle.${AWS_REGION}.api.aws/openai/v1. v1 substitutes it through the bedrock loader'svars()hook (added in #31001, expanded atpackages/opencode/src/provider/provider.ts:1712). The v2 plugin never did: it resolves a region for the SDK but leavesoptions.baseURLalone, andpackages/core/src/aisdk.ts:80assignsmodel.api.urlverbatim. So everyopenai.*Bedrock model on v2 requested that literal hostname and could not connect.This ports the same substitution to
packages/core/src/plugin/provider/amazon-bedrock.ts, reusing the region the plugin already resolves (configregion->AWS_REGION->us-east-1). It runs after theendpointoverride so a VPC endpoint still wins. That matches how the other v2 plugins expand their own templates (google-vertex.ts:78,cloudflare-workers-ai.ts:64) — bedrock was simply missing it.Also documents the Bedrock OpenAI models in
providers.mdx: they are served by the OpenAI-compatible endpoint rather than Converse, and are in fewer regions than the rest of the catalog. A wrong region produces a failure indistinguishable from this bug, so it seemed worth writing down next to the fix.How did you verify your code works?
Added two tests to
packages/core/test/plugin/provider-amazon-bedrock.test.ts— one for a config-supplied region, one forAWS_REGIONfrom the env — covering both/openai/v1(responses) and/v1(chat, used bygpt-oss-safeguard-*). Both were red before the change:From
packages/core:19 pass, 1 fail. Two caveats a reviewer will hit locally, neither caused by this change (both reproduce with it stashed):
dev.bun test test/plugin/provider-amazon-bedrock.test.tsalone dies withReferenceError: Cannot access 'AmazonBedrockPlugin' before initializationfrom a TDZ cycle atpackages/core/src/plugin/provider.ts:38. Loading any non-provider test file first avoids it, hence the two paths above.uses SigV4 credential env when bearer token is absent, which hits the real AWS credential chain and fails on my machine with an expired SSO token.Also ran
bun typecheckfrompackages/core: clean.Screenshots / recordings
Not a UI change.
Checklist
Re the duplicate bot's suggestion of #35787: that one prompts for a region during
/connecton the v1 provider and touchespackages/opencode. This is the v2 plugin failing to expand a catalog URL template. They do both edit the Bedrock section ofproviders.mdx, but different hunks.🤖 Generated with Claude Code