fix: detect SSE stream error events instead of silently discarding them#192
Merged
Conversation
…carding them (#144) Add ClassVar-driven error detection to the base Stream class. Mid-stream error events from providers (e.g. Anthropic overloaded_error, OpenAI server_error) now raise StreamEventError instead of being silently skipped. - Add _error_type_fields ClassVar and _build_error_from_value helper to Stream - Add _parse_stream_error base implementation handling type-based and field-based SSE error patterns - Add StreamEventError exception with error_type, event_data, provider attributes - Add raise_for_status() to stream_post() for HTTP-level errors - Provider overrides use ClassVar only (Google GenerateContent) or ClassVar + helper (Google Interactions, OpenResponses) - Remove dead SSE_EVENT_ERROR constant from Anthropic config
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #144
overloaded_error, OpenAIserver_error) were silently discarded — the consumer received partial content with no indication of failure_parse_stream_errorto the baseStreamclass, handling both generic SSE error patterns (type-based and field-based) via a single_error_type_fieldsClassVar_build_error_from_valuehelper for shared error extraction logicStreamEventErrorexception witherror_type,event_data,providerattributesraise_for_status()tostream_post()for HTTP-level errors_parse_stream_erroroverrides (Google Interactions, OpenResponses) — all others use the base or ClassVar-only overrideSSE_EVENT_ERRORconstant from Anthropic configTest plan