mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-09-27 03:31:48 +02:00
chore: fix text parsing for issue validation
This commit is contained in:
@@ -116,13 +116,14 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
RESPONSE_FILE: ${{ steps.validate.outputs.response-file }}
|
RESPONSE_FILE: ${{ steps.validate.outputs.response-file }}
|
||||||
RESPONSE: ${{ steps.validate.outputs.response }}
|
|
||||||
run: |
|
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
|
if [ -n "$RESPONSE_FILE" ] && [ -f "$RESPONSE_FILE" ]; then
|
||||||
|
echo "Reading response from file: $RESPONSE_FILE"
|
||||||
RAW_OUTPUT=$(cat "$RESPONSE_FILE")
|
RAW_OUTPUT=$(cat "$RESPONSE_FILE")
|
||||||
else
|
else
|
||||||
RAW_OUTPUT="$RESPONSE"
|
echo "::error::Response file not found: $RESPONSE_FILE"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract JSON if wrapped in markdown code fences; otherwise use raw
|
# Extract JSON if wrapped in markdown code fences; otherwise use raw
|
||||||
@@ -131,6 +132,14 @@ jobs:
|
|||||||
JSON_RESULT="$RAW_OUTPUT"
|
JSON_RESULT="$RAW_OUTPUT"
|
||||||
fi
|
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
|
# Parse JSON fields
|
||||||
IS_VALID=$(echo "$JSON_RESULT" | jq -r '.is_valid // false')
|
IS_VALID=$(echo "$JSON_RESULT" | jq -r '.is_valid // false')
|
||||||
ISSUE_TYPE=$(echo "$JSON_RESULT" | jq -r '.issue_type // "other"')
|
ISSUE_TYPE=$(echo "$JSON_RESULT" | jq -r '.issue_type // "other"')
|
||||||
|
|||||||
Reference in New Issue
Block a user