Skip to content

Error messages hidden by output sanitization when is_error: true #880

@shcv

Description

@shcv

Description

When an invalid model ID causes an API error, the helpful error message is hidden by the action's output sanitization, leaving users with only an opaque "process exited with code 1" error and minified code context.

Root Cause

The action's sanitizeSdkOutput function in base-action/src/run-claude-sdk.ts (lines 105-119) deliberately omits the result field from result messages:

if (message.type === "result") {
  const resultMsg = message as SDKResultMessage;
  return JSON.stringify(
    {
      type: "result",
      subtype: resultMsg.subtype,
      is_error: resultMsg.is_error,
      duration_ms: resultMsg.duration_ms,
      num_turns: resultMsg.num_turns,
      total_cost_usd: resultMsg.total_cost_usd,
      permission_denials: resultMsg.permission_denials,
      // NOTE: 'result' field is NOT included - this hides error messages!
    },
    null,
    2,
  );
}

When is_error: true, the result field contains the actual error message (e.g., "API Error: 404 model not found"), but this is never shown to the user.

Reproduction

Workflow configuration with invalid model ID:

- uses: anthropics/claude-code-action@v1
  with:
    claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
    claude_args: |
      --model claude-sonnet-4-5-20250514

What User Sees

{
  "type": "result",
  "subtype": "success",
  "is_error": true,
  "duration_ms": 230,
  "num_turns": 1,
  "total_cost_usd": 0,
  "permission_denials": []
}
SDK execution error: 14 |     depsCount: ${Q},
15 |     deps: ${$}}`};var Pj={keyword:"dependencies"...
...
error: Claude Code process exited with code 1

No indication of what went wrong. The minified code dump is just coincidental context, not the actual error.

What User Should See

{
  "type": "result",
  "subtype": "success",
  "is_error": true,
  "duration_ms": 230,
  "result": "API Error: 404 {\"type\":\"error\",\"error\":{\"type\":\"not_found_error\",\"message\":\"model: claude-sonnet-4-5-20250514\"}}",
  ...
}

Suggested Fix

In base-action/src/run-claude-sdk.ts, include the result field when is_error is true:

if (message.type === "result") {
  const resultMsg = message as SDKResultMessage;
  return JSON.stringify(
    {
      type: "result",
      subtype: resultMsg.subtype,
      is_error: resultMsg.is_error,
      duration_ms: resultMsg.duration_ms,
      num_turns: resultMsg.num_turns,
      total_cost_usd: resultMsg.total_cost_usd,
      permission_denials: resultMsg.permission_denials,
      // Include result field when there's an error
      ...(resultMsg.is_error && { result: resultMsg.result }),
    },
    null,
    2,
  );
}

Environment

  • Action Version: anthropics/claude-code-action@v1
  • SDK Version: 0.2.23
  • Claude Code Version: 2.1.23

Workaround

Enable show_full_output: true in your workflow to see full error messages:

- uses: anthropics/claude-code-action@v1
  with:
    show_full_output: true
    # ...

Or run in debug mode by setting the ACTIONS_STEP_DEBUG secret to true.

Related PRs

Note

This fix may also help with #874 (unhelpful error message when API key has no credits) - the actual API error message is likely being hidden by the same sanitization logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdev-experiencep2Non-showstopper bug or popular feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions