Skip to content

fix: route Bedrock SSE error events to the error handler#1475

Open
xodn348 wants to merge 1 commit intoanthropics:mainfrom
xodn348:fix/issue-1472
Open

fix: route Bedrock SSE error events to the error handler#1475
xodn348 wants to merge 1 commit intoanthropics:mainfrom
xodn348:fix/issue-1472

Conversation

@xodn348
Copy link
Copy Markdown

@xodn348 xodn348 commented Apr 30, 2026

Fixes #1472

What

The Bedrock AWSEventStreamDecoder previously hardcoded all SSE events as event="completion", causing error payloads (e.g. rate_limit_error) from Bedrock to be deserialized as RawMessageStartEvent with message=None instead of being routed to the existing error handler. This resulted in AttributeError: 'NoneType' object has no attribute 'model' crashes during streaming.

This fix inspects the decoded event payload and emits event="error" for events with "type": "error", allowing the existing error handling path in Stream.__stream__() to raise a proper APIStatusError.

Verification

  • Build: pass
  • Tests: pass (29 passed — streaming + bedrock decoder tests)
  • Lint: pass (ruff check)
  • Type check: pass (pyright 0 errors)

…1472)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sevakva
Copy link
Copy Markdown

sevakva commented Apr 30, 2026

Hey @xodn348
I've opened a PR #1479 that implements a broader fix for bedrock errors, including error codes mapping to anthropic errors. That handles other streaming errors and propagates exact errors to the user

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.

Streaming error SSE event causes AttributeError: 'NoneType' object has no attribute errors

2 participants