Repository navigation
fix(responses): preserve top-level fields on in-stream error events - #45142
Closed
zichen0116 wants to merge 1 commit into
Closed
zichen0116 wants to merge 1 commit into
zichen0116 wants to merge 1 commit into
Conversation
Contributor
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
|
Thanks for this. Superseded by #46438, now merged, which reads the same top-level code and message fields, so closing this one |
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.
TLDR
Problem this solves:
How it solves it:
errorevent has no nested error object, read the top-level code, message and param fieldsinvalid_promptnow raisesBadRequestError400 directly instead of a fallback-eligible 500User Flow
Before: a caller fault mid-stream surfaces as a retryable 500 with the provider reason lost
POST /v1/responsesand the provider ends the stream with anerrorevent carryingcode: invalid_promptMidStreamFallbackErrorsaying only "Response API in-stream error"After: the same event surfaces the provider reason as a 400 with no fallback
POST /v1/responsesand the provider ends it with the sameerroreventBadRequestErrorcarryinginvalid_promptand the provider messageRelevant issues
Fixes #45122
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Screenshots / Proof of Fix
Repro is the issue's own stub-server script: a local HTTP server streams
response.createdthen the OpenAI-shapederrorevent (code: invalid_prompt) throughlitellm.aresponses(model="openai/gpt-4.1", stream=True), no provider key neededBefore (f0031e9)
MidStreamFallbackError InternalServerError 500 ... Response API in-stream errorAfter (18f86a2)
BadRequestError BadRequestError 400 ... Invalid prompt: your prompt was flagged.Mutation check on the new unit test: it fails on the base commit (raises
MidStreamFallbackError) and passes with the fix; the fulltests/unit/responses/test_streaming_iterator_error_events.pyfile passes (60 passed), and ruff check plus format are clean on both changed filesType
🐛 Bug Fix
Final Attestation