chore: fix text parsing for issue validation

This commit is contained in:
zhom
2025-12-25 11:02:40 +04:00
parent bcca0b9a3a
commit 7b756be072
+12 -3
View File
@@ -116,13 +116,14 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RESPONSE_FILE: ${{ steps.validate.outputs.response-file }}
RESPONSE: ${{ steps.validate.outputs.response }}
run: |
# Prefer reading from the response file to avoid output truncation
# Read from the response file (RESPONSE env var gets truncated for large outputs)
if [ -n "$RESPONSE_FILE" ] && [ -f "$RESPONSE_FILE" ]; then
echo "Reading response from file: $RESPONSE_FILE"
RAW_OUTPUT=$(cat "$RESPONSE_FILE")
else
RAW_OUTPUT="$RESPONSE"
echo "::error::Response file not found: $RESPONSE_FILE"
exit 1
fi
# Extract JSON if wrapped in markdown code fences; otherwise use raw
@@ -131,6 +132,14 @@ jobs:
JSON_RESULT="$RAW_OUTPUT"
fi
# Validate JSON before parsing
if ! echo "$JSON_RESULT" | jq empty 2>/dev/null; then
echo "::error::Invalid JSON in AI response"
echo "Raw output:"
echo "$RAW_OUTPUT"
exit 1
fi
# Parse JSON fields
IS_VALID=$(echo "$JSON_RESULT" | jq -r '.is_valid // false')
ISSUE_TYPE=$(echo "$JSON_RESULT" | jq -r '.issue_type // "other"')