fix(aws): extract HTTP status code from AWS SDK errors - #2329
Conversation
WalkthroughAdds a helper to extract HTTP status codes from AWS SDK errors and replaces hardcoded HTTP 500 with derived status codes in three AWS error paths (InvokeModel, InvokeModelWithResponseStream, and Nova request handling) within Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
relay/channel/aws/relay-aws.go(4 hunks)
🔇 Additional comments (4)
relay/channel/aws/relay-aws.go (4)
191-192: LGTM: Proper status code extraction for InvokeModel errors.The error handling correctly extracts the AWS status code and propagates it to the client, resolving the issue where upstream 400/403 errors were being returned as 500.
218-219: LGTM: Consistent status code handling for streaming responses.The streaming error handler follows the same pattern as the non-streaming handler, ensuring consistent status code propagation across both AWS invocation methods.
258-259: LGTM: Nova request error handling aligned with other handlers.The Nova-specific handler correctly implements the same status code extraction pattern, ensuring all three AWS Bedrock invocation paths (standard, streaming, and Nova) return accurate HTTP status codes.
25-25: Smithy-go v1.22.5 is compatible with aws-sdk-go-v2 v1.37.2 — the import addition is appropriate.Web verification confirms that smithy-go v1.22.5 is the correct dependency for aws-sdk-go-v2 v1.37.2. Both versions were released contemporaneously (July 2025), and aws-sdk-go-v2 v1.37.x releases explicitly depend on smithy-go v1.22.x. Later SDK releases subsequently bumped to smithy-go v1.23.0, but this version pairing is valid and well-supported.
…-err-code fix(aws): extract HTTP status code from AWS SDK errors
PR 类型
PR 是否包含破坏性更新?
PR 描述
问题:
AWS Bedrock 渠道在调用失败时,无论上游返回什么状态码(如 400 参数错误),都会被包装成
500 Internal Server Error返回给客户端。修复:
getAwsErrorStatusCode函数,通过 smithy-go 的HTTPStatusCode()接口从 AWS SDK 错误中提取真实的 HTTP 状态码awsHandler、awsStreamHandler、handleNovaRequest三处错误处理逻辑,使用提取到的状态码替代硬编码的 500影响范围:
仅影响 AWS Bedrock 渠道的错误响应状态码,不影响正常请求流程。
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.