Skip to content

fix: avoid 'success' as error text when errors list is empty#1039

Open
ashishpatel26 wants to merge 1 commit into
anthropics:mainfrom
ashishpatel26:fix/issue-1031-misleading-success-error-message
Open

fix: avoid 'success' as error text when errors list is empty#1039
ashishpatel26 wants to merge 1 commit into
anthropics:mainfrom
ashishpatel26:fix/issue-1031-misleading-success-error-message

Conversation

@ashishpatel26

Copy link
Copy Markdown

Summary

Resolves #1031

When the CLI emits is_error=True with an empty errors[] array and subtype="success", the SDK was producing the misleading message:

Claude Code returned an error result: success

The fallback logic now skips "success" as an error label and uses "unknown error" instead.

Changes Made

  • src/claude_agent_sdk/_internal/query.py: fix fallback in _read_messages so subtype="success" is never used as the error description
  • tests/test_query.py: add regression tests covering empty errors[] with subtype="success", meaningful subtype, non-empty errors list, and the no-error (success) case

Testing

  • Regression tests added in tests/test_query.py
  • All existing tests pass (python -m pytest tests/test_query.py -x -q → 41 passed)
  • Ruff lint and format: all checks passed

Related Issue

Closes #1031

…ics#1031)

When the CLI emits is_error=True with an empty errors[] array and
subtype='success', the SDK was producing the misleading message
'Claude Code returned an error result: success'. The fallback now
skips 'success' as a subtype label and uses 'unknown error' instead.
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.

Misleading error message: 'Claude Code returned an error result: success' when errors[] is empty

1 participant