-
Notifications
You must be signed in to change notification settings - Fork 0
fix: handle Claude CLI non-zero exit codes #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…rror Claude CLI can return non-zero exit codes even for successful operations. This change wraps the run_process() call in a try-except block to catch CalledProcessError and create CoderOutput manually, allowing the existing JSON parsing logic to determine success/failure based on the is_error field. Fixes #8 Co-authored-by: Dragon-AI Agent <dragon-ai-agent@users.noreply.github.com>
Claude finished @justaddcoffee's task —— View job Code Review Complete ✅I've thoroughly reviewed this PR and the changes look good overall. Here's my feedback: Todo List:
🎯 SummaryThis PR properly addresses the issue where Claude CLI returns non-zero exit codes for successful operations. The solution correctly wraps the ✅ Strengths
🔍 Technical AnalysisCode Quality: The implementation follows the existing patterns in the codebase and integrates well with the error handling strategy at lines 251-253. Error Handling: The approach is sound - instead of failing immediately on non-zero exit codes, it lets the Claude CLI's own error reporting mechanism (via the Integration: The fix works well with the existing architecture where 🟡 Minor Suggestions
🧪 Test CoverageCurrent State: The existing tests in Recommendation: Consider adding a test case that simulates the CalledProcessError scenario to ensure the fix works correctly. Something like: def test_claude_handles_non_zero_exit_with_valid_json():
"""Test that ClaudeCoder handles non-zero exit codes when JSON output is valid."""
# Mock subprocess.CalledProcessError with valid JSON in stdout
# Verify that CoderOutput is created and success is determined by is_error field 🔒 Security & Performance
🎉 VerdictLGTM! This is a well-implemented fix that correctly addresses the issue. The code is clean, well-documented, and preserves existing functionality while solving the problem. Minor Enhancement: Adding a test case for this scenario would improve robustness, but the current implementation is solid and ready for merge. |
Claude finished @justaddcoffee's task —— View job Claude Code Review Complete ✅ Todo List:
🎯 SummaryThis PR correctly addresses issue #8 where Claude CLI returns non-zero exit codes for successful operations. The fix wraps the ✅ Strengths
🔍 Code Quality AnalysisArchitecture Integration: The solution fits cleanly into the existing codebase architecture where Import Management: The Exception Handling: The specific exception handling for 🟡 Minor Observations
🔒 Security & Performance
🧪 Test Coverage AssessmentCurrent State: The existing tests in Gap Identified: No test coverage for the Recommendation: Consider adding a test case like: def test_claude_handles_non_zero_exit_with_valid_json():
"""Test that ClaudeCoder handles non-zero exit codes when JSON output is valid."""
# Test scenario where CLI returns non-zero exit code but has valid JSON with is_error: false
# Verify that CoderOutput.success is correctly determined by the is_error field This would ensure the fix works correctly and prevent regressions. 🚀 Edge Cases ConsideredThe implementation handles key edge cases well:
🎉 VerdictAPPROVED ✅ This is a solid implementation that correctly fixes the issue. The code is:
Enhancement Suggestion: Adding test coverage for this scenario would improve robustness, but the current implementation is ready for merge. |
Fixes issue #8 where Claude CLI returns non-zero exit codes for successful operations.
This change wraps the run_process() call in a try-except block to catch CalledProcessError and create CoderOutput manually, allowing the existing JSON parsing logic to determine success/failure based on the is_error field.
Generated with Claude Code