Repository navigation
fix(relay/channel/aws): 修复AnthropicBeta字段的omitempty处理 - #2226
Conversation
WalkthroughThe Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
relay/channel/aws/dto.go (1)
43-46: Good defensive validation before assignment.The roundtrip validation (marshal → unmarshal) ensures the header values produce valid, non-empty JSON before setting AnthropicBeta. This pairs well with the
omitemptytag to prevent sending empty or malformed beta features to AWS Bedrock.Minor simplification opportunity: The check
len(betaJson) > 0on line 44 is redundant sincelen(tempArray) != 0already implies betaJson is non-empty. You could simplify to:- if err := json.Unmarshal(betaJson, &tempArray); err == nil && len(tempArray) != 0 && len(betaJson) > 0 { + if err := json.Unmarshal(betaJson, &tempArray); err == nil && len(tempArray) != 0 {Note: The current logic doesn't filter individual empty strings from the array (e.g.,
["", "feature-1"]would be accepted as-is). This is likely fine for AWS Bedrock's handling, but worth noting if stricter validation is needed in the future.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
relay/channel/aws/dto.go(2 hunks)
🔇 Additional comments (1)
relay/channel/aws/dto.go (1)
15-15: LGTM! Theomitemptytag correctly makes AnthropicBeta optional.This prevents the field from appearing in the JSON output when it's empty or nil, which aligns with AWS Bedrock's expectations for optional beta features.
…eta-empty fix(relay/channel/aws): 修复AnthropicBeta字段的omitempty处理
…eta-empty fix(relay/channel/aws): 修复AnthropicBeta字段的omitempty处理
…eta-empty fix(relay/channel/aws): 修复AnthropicBeta字段的omitempty处理
Summary by CodeRabbit
Bug Fixes