refactor(tools): drop dead repair_json call in _validate_tool_input#6162
refactor(tools): drop dead repair_json call in _validate_tool_input#6162i-anubhav-anand wants to merge 1 commit into
Conversation
In the ast.literal_eval failure branch, `repaired_input = repair_json(tool_input)` was assigned but never used — it is unconditionally reassigned (and the actual repair performed) a few lines later in the json.loads/repair fallback. Removing the dead store drops a redundant repair_json() call and matches the sibling except branches (which simply `pass`). No behavior change.
|
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 (1)
📝 WalkthroughWalkthroughIn ChangesJSON Parsing Fallback Adjustment
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Summary
In
ToolUsage._validate_tool_input, theast.literal_evalfailure branch did:repaired_inputis never read here — it is unconditionally reassigned a few lines later, where the actual repair is performed:So the first
repair_json(tool_input)call is a dead store that does redundant work and never affects the result.Change
Replace the dead assignment with
pass, matching the otherexceptbranches in the same function. No behavior change — the repair still happens via the existingjson.loads/repair_jsonfallback.Testing
uv run pytest tests/tools/test_tool_usage.py -k validate_tool_input→ 15 passed (incl.test_validate_tool_input_invalid_json_repairable, which exercises the repair path).ruff check/ruff format --checkclean.Summary by CodeRabbit