SDK crashes on unknown message type: rate_limit_event

Resolved 💬 3 comments Opened Mar 22, 2026 by niels1991d Closed Mar 25, 2026

Bug

claude-code-sdk v0.0.25 raises MessageParseError when receiving a rate_limit_event message type from the CLI.

Traceback:

File "claude_code_sdk/query.py", line 123, in query
    async for message in client.process_query(
File "claude_code_sdk/_internal/client.py", line 118, in process_query
    yield parse_message(data)
File "claude_code_sdk/_internal/message_parser.py", line 172, in parse_message
    raise MessageParseError(f"Unknown message type: {message_type}", data)
claude_code_sdk._errors.MessageParseError: Unknown message type: rate_limit_event

Root cause: The match statement in parse_message() has a case _: that raises for any unrecognized type. When the CLI emits rate_limit_event (e.g. during high-traffic periods), the entire async generator in process_query crashes — the Python generator is exhausted after an unhandled exception, so no further messages can be received.

Expected behavior: Unknown message types should be gracefully skipped (logged as debug) or exposed as a generic event type, not crash the stream.

Environment:

  • claude-code-sdk==0.0.25 (latest on PyPI)
  • Python 3.12 on Ubuntu 24.04
  • Claude Code CLI installed via npm

Workaround: We monkey-patch parse_message to return None for unknown types.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗