Skip to content

Fix Bedrock crossRegion check for string values from UI#5577

Open
colegottdank wants to merge 1 commit intomainfrom
fix/bedrock-cross-region-string
Open

Fix Bedrock crossRegion check for string values from UI#5577
colegottdank wants to merge 1 commit intomainfrom
fix/bedrock-cross-region-string

Conversation

@colegottdank
Copy link
Collaborator

Summary

  • Fixes the Bedrock cross-region inference profile feature for BYOK users
  • The UI stores crossRegion as a string ("true"/"false") but the code was checking it as a boolean
  • This caused the inference profile prefix (e.g., us.) to not be added when users enabled "Cross Region" in the UI

Root Cause

When a user checks "Cross Region" in the Bedrock provider settings, the config stores:

  • crossRegion: "true" (string)

But the code was doing:

if (userEndpointConfig.crossRegion && userEndpointConfig.region) {

Since "false" is truthy in JavaScript, this check was incorrect.

Fix

Now explicitly checks for both boolean true and string "true":

const isCrossRegion = userEndpointConfig.crossRegion === true || userEndpointConfig.crossRegion === "true";

Test plan

  • Added tests for string "true" case
  • Added tests for string "false" case
  • All existing tests pass
  • Test in production with Bedrock BYOK after deployment

🤖 Generated with Claude Code

The UI stores crossRegion as a string ("true"/"false") but the code
was checking it as a boolean. This caused the inference profile prefix
to not be added when crossRegion was set to "true" from the UI.

Now correctly handles both boolean true and string "true".

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
helicone Error Error Feb 17, 2026 9:53pm
helicone-bifrost Error Error Feb 17, 2026 9:53pm
helicone-eu Error Error Feb 17, 2026 9:53pm

Request Review

@supabase
Copy link

supabase bot commented Feb 17, 2026

This pull request has been ignored for the connected project bolqqmqbrciybnypvklh because there are no changes detected in supbase/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@supabase
Copy link

supabase bot commented Feb 17, 2026

This pull request has been ignored for the connected project lmahfbbnchpworytrrqk because there are no changes detected in .supabase/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@claude
Copy link
Contributor

claude bot commented Feb 17, 2026

Claude finished @colegottdank's task —— View job


Code Review Complete ✅

Todo List:

  • Read and analyze the changed files
  • Review the logic fix implementation
  • Analyze test coverage and quality
  • Provide comprehensive feedback with confidence score

Score: 8/10 - Solid fix with good test coverage, minor suggestions for improvement

Core Analysis

The fix correctly addresses the JavaScript truthy evaluation issue where "false" was being treated as truthy. The solution is clean and well-implemented.

✅ What's Good:

  • Correct Logic: The explicit check for both boolean true and string "true" properly handles the type mismatch between UI (string) and expected behavior (boolean)
  • Comprehensive Tests: Added test cases for both string "true" and "false" scenarios, plus existing boolean test
  • Clear Documentation: Good inline comment explaining the dual type expectation
  • Backwards Compatible: Maintains support for existing boolean usage while fixing string case

Suggestions for Improvement

1. Type Safety Enhancement (packages/cost/models/providers/bedrock.ts:31)

Consider making the type expectation more explicit:

// Current
const isCrossRegion = userEndpointConfig.crossRegion === true || userEndpointConfig.crossRegion === "true";

// Suggestion: Add type safety with helper function
private parseBoolean(value: unknown): boolean {
  return value === true || value === "true";
}

// Then use:
const isCrossRegion = this.parseBoolean(userEndpointConfig.crossRegion);

This would make the intention clearer and provide a reusable pattern for similar UI/API type mismatches.

2. Additional Test Coverage

The tests are good but could include edge cases:

// Missing edge cases to consider:
it("should handle undefined crossRegion", () => { /* ... */ });
it("should handle null crossRegion", () => { /* ... */ });
it("should handle numeric 0/1 values if they might occur", () => { /* ... */ });

3. Consider Interface Documentation

The UserEndpointConfig interface might benefit from JSDoc comments indicating that crossRegion can be either boolean or string to prevent future confusion.

Code Quality Assessment

✅ Strengths:

  • Minimal, focused change that doesn't over-engineer
  • Clear, descriptive variable names (isCrossRegion)
  • Good separation of concerns in the getModelId helper method
  • Proper test placement and naming conventions

✅ Performance & Security:

  • No performance impact (simple equality checks)
  • No security concerns introduced
  • Maintains existing AWS authentication flow

Minor Observations

  1. String Parsing: The current approach is fine, but could consider using a more explicit boolean parser if this pattern appears elsewhere in the codebase
  2. Error Handling: The existing error handling for missing region is appropriate and unchanged
  3. Region Prefix Logic: The region parsing (split("-")[0]) looks correct for AWS region format

Summary

This is a well-executed bug fix that demonstrates good understanding of the problem and implements a clean solution. The addition of comprehensive test cases shows attention to quality. The only suggestions are minor enhancements for type safety and edge case handling.

Recommendation: Ready to merge with the minor suggestions considered for future improvements.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant