Skip to content

fix: show error result in sanitized SDK output#917

Open
Dave-London wants to merge 1 commit intoanthropics:mainfrom
Dave-London:fix/show-error-result-in-sanitized-output
Open

fix: show error result in sanitized SDK output#917
Dave-London wants to merge 1 commit intoanthropics:mainfrom
Dave-London:fix/show-error-result-in-sanitized-output

Conversation

@Dave-London
Copy link
Contributor

Summary

  • Includes the result field in sanitized SDK output when is_error is true
  • Non-error results remain hidden to protect sensitive output
  • Exports sanitizeSdkOutput for testability and adds 5 unit tests

Problem

When a Claude SDK execution fails (e.g., invalid model ID, API errors), the sanitizeSdkOutput function strips the result field from the output. This hides the actual error message, leaving users with only an opaque "process exited with code 1" and minified code context.

Users see:

{"type": "result", "is_error": true, "duration_ms": 230}

Instead of:

{"type": "result", "is_error": true, "result": "API Error: 404 model not found", "duration_ms": 230}

Changes

  • base-action/src/run-claude-sdk.ts: Conditionally spread result when is_error is true, with "result" in resultMsg type guard for the SDKResultSuccess/SDKResultError union
  • test/sanitize-sdk-output.test.ts: 5 tests covering error result inclusion, success result omission, init messages, and message suppression

Test plan

  • 5/5 sanitize-sdk-output tests pass
  • TypeScript typecheck passes
  • Prettier formatting passes

Fixes #880

Include the `result` field in sanitized output when `is_error` is true,
so users can see the actual error message (e.g. "API Error: 404 model
not found") instead of an opaque "process exited with code 1".

Non-error results remain hidden to protect sensitive output.

Fixes anthropics#880

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error messages hidden by output sanitization when is_error: true

1 participant