From 7b756be072fbd199190f305f61fbfc4cae76b912 Mon Sep 17 00:00:00 2001 From: zhom <2717306+zhom@users.noreply.github.com> Date: Thu, 25 Dec 2025 11:02:40 +0400 Subject: [PATCH] chore: fix text parsing for issue validation --- .github/workflows/issue-validation.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/issue-validation.yml b/.github/workflows/issue-validation.yml index 62069b6..39ac0f3 100644 --- a/.github/workflows/issue-validation.yml +++ b/.github/workflows/issue-validation.yml @@ -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"')