Fix Bedrock crossRegion check for string values from UI#5577
Fix Bedrock crossRegion check for string values from UI#5577colegottdank wants to merge 1 commit intomainfrom
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Claude finished @colegottdank's task —— View job Code Review Complete ✅Todo List:
Score: 8/10 - Solid fix with good test coverage, minor suggestions for improvement Core AnalysisThe fix correctly addresses the JavaScript truthy evaluation issue where ✅ What's Good:
Suggestions for Improvement1. 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 CoverageThe 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 DocumentationThe Code Quality Assessment✅ Strengths:
✅ Performance & Security:
Minor Observations
SummaryThis 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. |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Summary
crossRegionas a string ("true"/"false") but the code was checking it as a booleanus.) to not be added when users enabled "Cross Region" in the UIRoot Cause
When a user checks "Cross Region" in the Bedrock provider settings, the config stores:
crossRegion: "true"(string)But the code was doing:
Since
"false"is truthy in JavaScript, this check was incorrect.Fix
Now explicitly checks for both boolean
trueand string"true":Test plan
"true"case"false"case🤖 Generated with Claude Code