From 2721c10e98a31cff2487035fed3187971ad64972 Mon Sep 17 00:00:00 2001 From: default Date: Thu, 11 Dec 2025 22:55:17 +0000 Subject: [PATCH] fix: add fallback extraction for classify-issue-severity workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The structured_output field is not consistently available in the result message, causing the workflow to fail with "Result exists: false". Root cause analysis: - structured_output only appears in result messages when the conversation completes successfully with subtype "success" - In GitHub Actions, the conversation may hit errors, permissions issues, or other failures that prevent successful completion - When this happens, the StructuredOutput tool is called but the result message doesn't include the structured_output field Solution - Implement robust fallback chain: 1. Try structured_output first (ideal path when it works) 2. Fall back to extracting from StructuredOutput tool call in execution file 3. Add debugging to show what messages exist for troubleshooting This approach handles both the happy path and the edge cases where structured_output isn't populated, ensuring the workflow works reliably. Changes: - Renamed step to "Extract Result with Fallback" - Added EXECUTION_FILE environment variable - Implement two-tier extraction: * Primary: Use structured_output if available * Fallback: Parse StructuredOutput tool call from execution file - Added diagnostic output showing message types - Improved error messages with emojis for clarity Fixes workflow run: https://github.com/coder/coder/actions/runs/20149903506 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- .github/workflows/classify-issue-severity.yml | 48 +++++++++++++++++-- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/.github/workflows/classify-issue-severity.yml b/.github/workflows/classify-issue-severity.yml index 6946bf37096ec..820021dd6edd0 100644 --- a/.github/workflows/classify-issue-severity.yml +++ b/.github/workflows/classify-issue-severity.yml @@ -142,20 +142,58 @@ jobs: **Critical**: Output ONLY the JSON object, nothing else. The JSON will be parsed and validated. - - name: Extract Result from Structured Output + - name: Extract Result with Fallback id: extract env: STRUCTURED_OUTPUT: ${{ steps.analysis.outputs.structured_output }} + EXECUTION_FILE: ${{ steps.analysis.outputs.execution_file }} run: | - if [ -z "$STRUCTURED_OUTPUT" ]; then - echo "No structured output returned from Claude" + # Try to use structured_output first (preferred method) + if [ -n "$STRUCTURED_OUTPUT" ] && [ "$STRUCTURED_OUTPUT" != "null" ]; then + echo "✅ Using structured_output from claude-code-action" + RESULT="$STRUCTURED_OUTPUT" + else + echo "⚠️ structured_output not available, falling back to execution file parsing" + + if [ ! -f "$EXECUTION_FILE" ]; then + echo "❌ Execution file not found: $EXECUTION_FILE" + exit 1 + fi + + # Debug: Show what messages we have + echo "Messages in execution file:" + jq -r '.[] | " - type: \(.type), subtype: \(.subtype // "none")"' < "$EXECUTION_FILE" || echo "Failed to parse execution file" + + # Try to extract from StructuredOutput tool call as fallback + echo "Attempting to extract from StructuredOutput tool call..." + RESULT=$(jq -r ' + .[] | + select(.type == "assistant") | + .message.content[] | + select(.type == "tool_use" and .name == "StructuredOutput") | + .input | + @json + ' < "$EXECUTION_FILE" | head -1) + + if [ -z "$RESULT" ] || [ "$RESULT" = "null" ]; then + echo "❌ Could not extract structured output from any source" + echo "Execution file contents:" + cat "$EXECUTION_FILE" + exit 1 + fi + + echo "✅ Extracted from StructuredOutput tool call" + fi + + # Validate the result is valid JSON + if ! echo "$RESULT" | jq -e . > /dev/null 2>&1; then + echo "❌ Result is not valid JSON: $RESULT" exit 1 fi - # The structured_output is already in JSON format matching our schema { echo "result<> "$GITHUB_OUTPUT"