fix(tools): raise ToolUsageError instead of bare raise in _original_tool_calling#6511
fix(tools): raise ToolUsageError instead of bare raise in _original_tool_calling#6511Aakash326 wants to merge 1 commit into
Conversation
…ool_calling Fixes crewAIInc#6430. The bare 'raise' in the non-dict-arguments branch of _original_tool_calling had no active exception to re-raise, so Python raised 'RuntimeError: No active exception to re-raise' instead of a meaningful ToolUsageError. Replaced it with an explicit 'raise ToolUsageError(...)' matching the sibling return statement and the pattern used elsewhere in this method. Co-authored-by: Cursor <cursoragent@cursor.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughChangesTool argument error handling
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
ErenAta16
left a comment
There was a problem hiding this comment.
Same one-line fix as #6486, #6512, #6511, #6499 — this is one of five open PRs (added this one to the tally) independently fixing the same bare-raise-outside-except bug in _original_tool_calling. Reproduced the bug standalone: the bare raise here raises RuntimeError: No active exception to reraise rather than the intended ToolUsageError, since it is outside any except block. This PR's fix is correct and equivalent to the others. Left a fuller comparison on #6486, which constructs the error once and reuses it for both branches rather than twice — noting the duplication here so only one lands.
Fixes #6430.
The bare
raisein the non-dict-arguments branch of_original_tool_callinghad no active exception to re-raise, so Python raised
RuntimeError: No active exception to re-raiseinstead of a meaningfulToolUsageError. Replaced it with an explicitraise ToolUsageError(...)matching the sibling
returnstatement and the pattern used elsewhere inthis method.
Added regression test covering both
raise_error=Trueandraise_error=Falsepaths.