fix: add fallback extraction for classify-issue-severity workflow #21242
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds a robust fallback mechanism to handle cases where
structured_outputis not available in the result message.Root Cause Analysis
After deep investigation, I discovered that
structured_outputis only added to the result message when the conversation completes successfully withsubtype: "success".What went wrong:
The workflow uses
--json-schemawhich makes Claude CLI provide aStructuredOutputtoolClaude calls this tool with the JSON data
However, if the conversation encounters:
Then the result message will have a different subtype (e.g.,
error_max_turns,error_permission_denied) and won't include thestructured_outputfield, even though theStructuredOutputtool was called successfully.Evidence from testing:
But the execution file DOES contain:
{ "type": "assistant", "message": { "content": [{ "type": "tool_use", "name": "StructuredOutput", "input": { "status": "classified", ... } }] } }Solution
Implement a two-tier fallback system:
Tier 1 (Preferred): Use structured_output
structured_outputis available from claude-code-action, use it directlyTier 2 (Fallback): Extract from StructuredOutput tool call
StructuredOutputtool callinputfield which contains our JSON dataDebugging
Changes
Why This Works
This approach is bulletproof because:
StructuredOutputtool when--json-schemais provided (as long as it generates output)Testing Strategy
The fallback will activate if:
In the happy path, it will use
structured_outputas intended.Supersedes
🤖 Generated with Claude Code