Skip to content

Commit 2721c10

Browse files
david-fraleyclaude
andcommitted
fix: add fallback extraction for classify-issue-severity workflow
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 <noreply@anthropic.com>
1 parent 8249ac8 commit 2721c10

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

.github/workflows/classify-issue-severity.yml

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,58 @@ jobs:
142142
143143
**Critical**: Output ONLY the JSON object, nothing else. The JSON will be parsed and validated.
144144
145-
- name: Extract Result from Structured Output
145+
- name: Extract Result with Fallback
146146
id: extract
147147
env:
148148
STRUCTURED_OUTPUT: ${{ steps.analysis.outputs.structured_output }}
149+
EXECUTION_FILE: ${{ steps.analysis.outputs.execution_file }}
149150
run: |
150-
if [ -z "$STRUCTURED_OUTPUT" ]; then
151-
echo "No structured output returned from Claude"
151+
# Try to use structured_output first (preferred method)
152+
if [ -n "$STRUCTURED_OUTPUT" ] && [ "$STRUCTURED_OUTPUT" != "null" ]; then
153+
echo "✅ Using structured_output from claude-code-action"
154+
RESULT="$STRUCTURED_OUTPUT"
155+
else
156+
echo "⚠️ structured_output not available, falling back to execution file parsing"
157+
158+
if [ ! -f "$EXECUTION_FILE" ]; then
159+
echo "❌ Execution file not found: $EXECUTION_FILE"
160+
exit 1
161+
fi
162+
163+
# Debug: Show what messages we have
164+
echo "Messages in execution file:"
165+
jq -r '.[] | " - type: \(.type), subtype: \(.subtype // "none")"' < "$EXECUTION_FILE" || echo "Failed to parse execution file"
166+
167+
# Try to extract from StructuredOutput tool call as fallback
168+
echo "Attempting to extract from StructuredOutput tool call..."
169+
RESULT=$(jq -r '
170+
.[] |
171+
select(.type == "assistant") |
172+
.message.content[] |
173+
select(.type == "tool_use" and .name == "StructuredOutput") |
174+
.input |
175+
@json
176+
' < "$EXECUTION_FILE" | head -1)
177+
178+
if [ -z "$RESULT" ] || [ "$RESULT" = "null" ]; then
179+
echo "❌ Could not extract structured output from any source"
180+
echo "Execution file contents:"
181+
cat "$EXECUTION_FILE"
182+
exit 1
183+
fi
184+
185+
echo "✅ Extracted from StructuredOutput tool call"
186+
fi
187+
188+
# Validate the result is valid JSON
189+
if ! echo "$RESULT" | jq -e . > /dev/null 2>&1; then
190+
echo "❌ Result is not valid JSON: $RESULT"
152191
exit 1
153192
fi
154193
155-
# The structured_output is already in JSON format matching our schema
156194
{
157195
echo "result<<EOF"
158-
echo "$STRUCTURED_OUTPUT"
196+
echo "$RESULT"
159197
echo "EOF"
160198
} >> "$GITHUB_OUTPUT"
161199

0 commit comments

Comments
 (0)