Skip to content

Conversation

@david-fraley
Copy link
Collaborator

Summary

Fixes the extraction error in the classify-issue-severity.yml workflow by using structured output instead of parsing the execution file.

Root Cause

The claude-code-action uses its own stream-json format (not the Anthropic Messages API format). Without --json-schema, the assistant's text response isn't available in a structured field in the execution file. The previous fix (#21238) tried to extract text from content arrays, but that doesn't match the actual format.

Solution

Use the claude-code-action's structured output feature:

  1. Add --json-schema parameter with a JSON schema that matches the expected output format

    • Defines required fields: status, reasoning
    • Conditional requirements based on status value
    • Enforces valid enum values for status and severity
  2. Use structured_output output directly from the claude-code-action

    • This is automatically populated when --json-schema is provided
    • No need to parse the execution file manually
  3. Simplify extraction step

    • Removed complex jq parsing
    • Now just passes through the structured output

Changes

  • Updated .github/workflows/classify-issue-severity.yml:
    • Added claude_args with --json-schema parameter
    • Changed extraction step from parsing execution_file to using structured_output
    • Renamed step to "Extract Result from Structured Output" for clarity

Verification

The structured output approach is the recommended way to extract data from claude-code-action, as shown in their test workflows:
https://github.com/anthropics/claude-code-action/blob/main/.github/workflows/test-structured-output.yml

Supersedes

🤖 Generated with Claude Code

The claude-code-action's execution file format doesn't include the
assistant's text response in an easily accessible field when not using
--json-schema. The previous fix attempted to parse the execution file
as Anthropic Messages API format, but claude-code uses its own format.

This fix:
1. Adds --json-schema parameter to enable structured output
2. Uses the structured_output output directly from claude-code-action
3. Removes the complex jq parsing of the execution file

The JSON schema enforces:
- Required fields: status, reasoning
- Conditional requirements based on status value
- Valid enum values for status and severity

Supersedes PR #21238

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@david-fraley david-fraley merged commit 48484af into main Dec 11, 2025
30 checks passed
@david-fraley david-fraley deleted the fix/classify-issue-severity-use-structured-output branch December 11, 2025 22:30
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants