fix: add missing [] defaults to 5 .get() calls in Bedrock span_utils#4334
fix: add missing [] defaults to 5 .get() calls in Bedrock span_utils#4334truecallerabreham wants to merge 1 commit into
Conversation
|
|
📝 WalkthroughWalkthroughFive span attribute helper functions in span_utils.py for the Bedrock instrumentation package were updated to use dict.get with an empty list default when reading "generations", "completions", or "results" keys from response bodies, preventing failures when those keys are absent. ChangesBedrock Response Field Defaulting
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
|
CLA was signed but status shows pending — could someone trigger a recheck? Thanks. |
Five .get() calls in span_utils.py iterate over the result without providing a default, so when the response body doesn't include the expected key you get a TypeError instead of gracefully skipping.
The pattern already exists on line 220 (response_body.get("generations", [])) but the other five sites using "generations", "completions", and "results" were missed. This hits Cohere, AI21, Meta/Llama, and Amazon Titan models in the non-streaming path.
Fix is adding [], nothing else changes.
Before / After: