Skip to content

Bedrock#1659

Open
Tiska wants to merge 9 commits intoMCPJam:mainfrom
sncf-connect-tech:bedrok
Open

Bedrock#1659
Tiska wants to merge 9 commits intoMCPJam:mainfrom
sncf-connect-tech:bedrok

Conversation

@Tiska
Copy link

@Tiska Tiska commented Mar 24, 2026

No description provided.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 24, 2026
@Tiska Tiska changed the title Bedrok Bedrock Mar 24, 2026
@chelojimenez
Copy link
Contributor

chelojimenez commented Mar 24, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@dosubot dosubot bot added the enhancement New feature or request label Mar 24, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 42abaae3-ae2e-491c-b215-9a7339a73a1c

📥 Commits

Reviewing files that changed from the base of the PR and between ff05013 and 8694a2c.

📒 Files selected for processing (1)
  • sdk/package.json
✅ Files skipped from review due to trivial changes (1)
  • sdk/package.json

Walkthrough

Adds Amazon Bedrock as a built-in provider by extending the LLMProvider union to include "bedrock" and updating the model factory to handle a "bedrock" branch. The model factory imports and constructs an Amazon Bedrock provider, using an AWS credential provider created via fromNodeProviderChain. sdk/package.json adds two runtime dependencies: @ai-sdk/amazon-bedrock and @aws-sdk/credential-providers. No exported or public API signatures were changed.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
sdk/package.json (1)

36-37: Duplicate build on publish.

Both prepare and prepublishOnly invoke npm run build. When publishing, this triggers two consecutive builds. Consider removing one or guarding against redundant work.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/package.json` around lines 36 - 37, The package.json defines both
"prepare" and "prepublishOnly" scripts invoking "npm run build", causing
redundant builds on publish; remove one of these keys (either "prepare" or
"prepublishOnly") or change one to a no-op/guard so "npm run build" runs only
once, e.g., keep "prepare": "npm run build" and delete "prepublishOnly" (or vice
versa), or implement an environment-check guard around "npm run build" so the
"prepare" and "prepublishOnly" scripts do not both execute the same build step.
sdk/src/model-factory.ts (1)

258-287: Document Bedrock environment variable configuration.

The code uses custom environment variables (BEDROCK_ROLE_ARN, BEDROCK_SOURCE_PROFILE, BEDROCK_PROFILE, AWS_REGION, AWS_PROFILE) with a specific precedence order for credential resolution, but they are not documented anywhere in the repository. Add documentation (in sdk/README.md or a configuration guide) explaining these variables and their resolution order: temporary credentials via BEDROCK_ROLE_ARN, then INI profile via BEDROCK_PROFILE/AWS_PROFILE, then Node provider chain fallback.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/src/model-factory.ts` around lines 258 - 287, Document the Bedrock
environment variable configuration and resolution order referenced in the
"bedrock" branch of sdk/src/model-factory.ts: explain BEDROCK_ROLE_ARN,
BEDROCK_SOURCE_PROFILE, BEDROCK_PROFILE, AWS_REGION, and AWS_PROFILE and the
precedence used by the code (use temporary credentials via BEDROCK_ROLE_ARN with
fromTemporaryCredentials/master fromIni(source profile) first, then INI profile
via fromIni(BEDROCK_PROFILE or AWS_PROFILE), then fallback to
fromNodeProviderChain), and show how these map to the createAmazonBedrock call
and region/credentialProvider behavior so users know how to configure
credentials and region for createAmazonBedrock/model selection.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@sdk/package.json`:
- Around line 69-77: The package.json entry for "@ai-sdk/amazon-bedrock" is
pinned to v3.0.84 and needs to be updated to the v4 major line; change the
dependency version for "@ai-sdk/amazon-bedrock" from "^3.0.84" to the current v4
range (for example "^4.0.83"), then run your package manager (npm/yarn/pnpm
install) and run the test/build to surface any breaking changes in code paths
that reference amazon-bedrock client initialization or types (search for usages
of "@ai-sdk/amazon-bedrock" and update imports or constructor calls as
required).

In `@sdk/src/model-factory.ts`:
- Around line 265-268: The role-assumption branch uses fromIni with profile:
bedrockSourceProfile ?? bedrockProfile and therefore ignores AWS_PROFILE,
causing inconsistent behavior with the non-role branch; update the source
credential selection in the bedrockRoleArn branch (where fromIni is called) to
use bedrockSourceProfile ?? bedrockProfile ?? process.env.AWS_PROFILE (or an
equivalent helper that reads AWS_PROFILE) so it falls back to AWS_PROFILE like
the non-role path, ensuring bedrockRoleArn, fromIni, bedrockSourceProfile and
bedrockProfile behave consistently.

---

Nitpick comments:
In `@sdk/package.json`:
- Around line 36-37: The package.json defines both "prepare" and
"prepublishOnly" scripts invoking "npm run build", causing redundant builds on
publish; remove one of these keys (either "prepare" or "prepublishOnly") or
change one to a no-op/guard so "npm run build" runs only once, e.g., keep
"prepare": "npm run build" and delete "prepublishOnly" (or vice versa), or
implement an environment-check guard around "npm run build" so the "prepare" and
"prepublishOnly" scripts do not both execute the same build step.

In `@sdk/src/model-factory.ts`:
- Around line 258-287: Document the Bedrock environment variable configuration
and resolution order referenced in the "bedrock" branch of
sdk/src/model-factory.ts: explain BEDROCK_ROLE_ARN, BEDROCK_SOURCE_PROFILE,
BEDROCK_PROFILE, AWS_REGION, and AWS_PROFILE and the precedence used by the code
(use temporary credentials via BEDROCK_ROLE_ARN with
fromTemporaryCredentials/master fromIni(source profile) first, then INI profile
via fromIni(BEDROCK_PROFILE or AWS_PROFILE), then fallback to
fromNodeProviderChain), and show how these map to the createAmazonBedrock call
and region/credentialProvider behavior so users know how to configure
credentials and region for createAmazonBedrock/model selection.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c7a02be5-a277-453a-9e00-ee0167bf0b0e

📥 Commits

Reviewing files that changed from the base of the PR and between 01b977f and 5f0dcf0.

📒 Files selected for processing (3)
  • sdk/package.json
  • sdk/src/model-factory.ts
  • sdk/src/types.ts

Comment on lines +265 to +268
if (bedrockRoleArn) {
const sourceCredentials = fromIni({
profile: bedrockSourceProfile ?? bedrockProfile,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Inconsistent AWS_PROFILE fallback for role assumption.

When BEDROCK_ROLE_ARN is set, source credentials derive from BEDROCK_SOURCE_PROFILE ?? BEDROCK_PROFILE, ignoring AWS_PROFILE. However, the non-role branch (line 277) does fall back to AWS_PROFILE. This asymmetry may surprise users who set BEDROCK_ROLE_ARN alongside AWS_PROFILE expecting it to be used.

🔧 Proposed fix for consistency
       const sourceCredentials = fromIni({
-        profile: bedrockSourceProfile ?? bedrockProfile,
+        profile: bedrockSourceProfile ?? bedrockProfile ?? process.env.AWS_PROFILE,
       });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (bedrockRoleArn) {
const sourceCredentials = fromIni({
profile: bedrockSourceProfile ?? bedrockProfile,
});
if (bedrockRoleArn) {
const sourceCredentials = fromIni({
profile: bedrockSourceProfile ?? bedrockProfile ?? process.env.AWS_PROFILE,
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/src/model-factory.ts` around lines 265 - 268, The role-assumption branch
uses fromIni with profile: bedrockSourceProfile ?? bedrockProfile and therefore
ignores AWS_PROFILE, causing inconsistent behavior with the non-role branch;
update the source credential selection in the bedrockRoleArn branch (where
fromIni is called) to use bedrockSourceProfile ?? bedrockProfile ??
process.env.AWS_PROFILE (or an equivalent helper that reads AWS_PROFILE) so it
falls back to AWS_PROFILE like the non-role path, ensuring bedrockRoleArn,
fromIni, bedrockSourceProfile and bedrockProfile behave consistently.

sdk/package.json Outdated
"@ai-sdk/mistral": "^2.0.19",
"@ai-sdk/openai": "^2.0.32",
"@ai-sdk/xai": "^2.0.29",
"@aws-sdk/credential-providers": "^3.998.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM post-pin resolve

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello, version is fixed :) thanks for your work, sdk is working great :)

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Mar 25, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
sdk/src/model-factory.ts (1)

258-264: Consider relaxing apiKey requirement for Bedrock callers.

This branch does not consume options.apiKey, but the public options type still requires it. Making API-key requirements provider-specific would avoid dummy values and improve SDK ergonomics.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/src/model-factory.ts` around lines 258 - 264, The public options type
requires apiKey even though the "bedrock" branch (in model-factory.ts using
fromNodeProviderChain() and createAmazonBedrock()) doesn't use it; change the
options typing to make apiKey optional for Bedrock callers by introducing a
provider-discriminated union or making apiKey optional in the generic options
interface, update any factory signature that returns ProviderLanguageModel to
accept the new type, and remove any forced/dummy apiKey usages so callers of
createAmazonBedrock/fromNodeProviderChain can omit apiKey.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@sdk/src/model-factory.ts`:
- Around line 258-264: The public options type requires apiKey even though the
"bedrock" branch (in model-factory.ts using fromNodeProviderChain() and
createAmazonBedrock()) doesn't use it; change the options typing to make apiKey
optional for Bedrock callers by introducing a provider-discriminated union or
making apiKey optional in the generic options interface, update any factory
signature that returns ProviderLanguageModel to accept the new type, and remove
any forced/dummy apiKey usages so callers of
createAmazonBedrock/fromNodeProviderChain can omit apiKey.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4784a0e8-a04d-4c95-a2ab-d601c129c54d

📥 Commits

Reviewing files that changed from the base of the PR and between 5f0dcf0 and 4215564.

⛔ Files ignored due to path filters (1)
  • sdk/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • sdk/package.json
  • sdk/src/model-factory.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants