fix: handle mid-stream error events in OpenAI SSE streaming#8027
Closed
dale-lakes wants to merge 1 commit intoblock:mainfrom
Closed
fix: handle mid-stream error events in OpenAI SSE streaming#8027dale-lakes wants to merge 1 commit intoblock:mainfrom
dale-lakes wants to merge 1 commit intoblock:mainfrom
Conversation
When an OpenAI-compatible server sends an error object mid-stream
(e.g. {"error": {"message": "..."}}) the deserializer would fail
trying to parse it as a StreamingChunk, crashing with "Stream decode
error". This format is used by vLLM, SGLang, Exo, and OpenAI itself.
Check for an error key before attempting StreamingChunk deserialization,
matching the pattern used by the official OpenAI Python client.
Closes block#8021
Signed-off-by: Clyde <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Collaborator
|
thanks @spitfire55 - in order to merge faster, we just push to branches these days. since yours is on a branch, I'll continue on #8301 and will close this |
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
errorkey in SSE data events before deserializing asStreamingChunkProblem
When an OpenAI-compatible server sends a mid-stream error like
{"error": {"message": "Internal server error", ...}},response_to_streaming_messagetries to deserialize it as aStreamingChunkand fails because there's nochoicesfield. This propagates asProviderError::RequestFailed("Stream decode error: error decoding response body"), killing the session.This error format is used by vLLM, SGLang, Exo, and OpenAI itself. The official OpenAI Python client handles it by checking
data.get("error")before deserialization.Fix
Added
parse_streaming_chunk()that checks for anerrorkey in the JSON before attemptingStreamingChunkdeserialization. Applied to both deserialization sites inresponse_to_streaming_message.Closes #8021