Repository navigation
fix(bedrock): return no output instead of throwing when a Nova message has no content - #11812
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11812 +/- ##
==========================================
- Coverage 89.33% 89.33% -0.01%
==========================================
Files 1030 1030
Lines 93013 93013
Branches 32882 32882
==========================================
- Hits 83093 83090 -3
- Misses 9920 9923 +3
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
👍 All Clear
Reviewed changes to Bedrock Nova response handling and associated tests. The PR makes message content optional and returns undefined instead of throwing when absent. Based on the diff, there are no new LLM-related security risks introduced.
Minimum severity threshold: 🟡 Medium | To re-scan after changes, comment @promptfoo-scanner
Learn more
|
Thanks @kabishou11 for tracing this through the Nova 2 handler. The I ran
How I checked
|
|
Thanks for the live Bedrock check — glad the Nova 1 paths stay identical and the crash is gone. |
novaOutputFromMessageinsrc/providers/bedrock/util.tsreadsresponse.output?.message?.content.some(...). The optional chain stops before.some, so a Nova response whose message has nocontentarray throws instead of producing an empty output:You don't need a malformed response to reach this. The Nova 2 handler in
src/providers/bedrock/index.tssends exactly this shape here: whencontentis missing or not an array, it callsnovaOutputFromMessage(responseJson). The Converse parser already treats missing content as empty (outputMessage?.content || []).The fix extends the optional chain to
content?.some/content?.map, so missing content returnsundefined, the same result as an empty response. Responses that have content are unchanged.Test:
should handle message without content without throwingintest/providers/bedrock/util.test.tsfails on main with the TypeError and passes with the fix. The file passes (8 tests), and Biome is clean.