Skip to content

Commit 0a6775a

Browse files
fix: capture and display ai-reviewer.sh error messages in workflow
Previously, when ai-reviewer.sh failed with exit code 1, the workflow would immediately stop due to shell errexit (-e flag) without displaying the actual error message. This made debugging failures very difficult. Changes: - Temporarily disable errexit with 'set +e' before running ai-reviewer.sh - Capture both stdout and stderr with '2>&1' redirection - Store the exit code separately for inspection - Re-enable errexit with 'set -e' after capture - Check exit code and display full error output if non-zero - Include exit code in debug output for better troubleshooting This fix ensures that when the AI reviewer fails, users will see the actual error message (e.g., "Missing OPENROUTER_API_KEY", "Diff too large", "API call failed") instead of just "Error: Process completed with exit code 1".
1 parent d03e896 commit 0a6775a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

.github/workflows/ai-code-reviewer.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,30 @@ jobs:
4646
run: |
4747
# Run the AI reviewer and save response to file
4848
echo "Running AI code review..."
49-
AI_RESPONSE=$(cat diff.txt | bash ai-reviewer.sh)
49+
50+
# Temporarily disable errexit to capture errors properly
51+
set +e
52+
AI_RESPONSE=$(cat diff.txt | bash ai-reviewer.sh 2>&1)
53+
EXIT_CODE=$?
54+
set -e
5055
5156
# Output raw response for debugging (only in debug mode)
5257
if [ "$DEBUG_MODE" = "true" ]; then
5358
echo "=== RAW AI RESPONSE FOR DEBUG ==="
59+
echo "Exit code: $EXIT_CODE"
5460
echo "$AI_RESPONSE"
5561
echo "=== END RAW AI RESPONSE ==="
5662
fi
5763
64+
# Check if the script failed
65+
if [ $EXIT_CODE -ne 0 ]; then
66+
echo "❌ AI reviewer script failed with exit code $EXIT_CODE"
67+
echo ""
68+
echo "Error output:"
69+
echo "$AI_RESPONSE"
70+
exit 1
71+
fi
72+
5873
# Check if AI_RESPONSE is empty
5974
if [ -z "$AI_RESPONSE" ]; then
6075
echo "❌ AI response is empty"

0 commit comments

Comments
 (0)