fix(openai): handle missing 'id' field in streaming chunks for MiniMax - #23931
Merged
RheagalFire merged 1 commit intoMar 19, 2026
Conversation
- Change chunk["id"] to chunk.get("id") for compatibility with MiniMax
- ModelResponseStream auto-generates id when None is passed
- Add regression test test_chunk_parser_without_id_field
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryThis PR fixes a Key changes:
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/llms/openai/chat/gpt_transformation.py | Single-line fix replacing chunk["id"] with chunk.get("id") in chunk_parser; ModelResponseStream already handles None by auto-generating an id via _generate_id(). |
| tests/test_litellm/llms/openai/chat/test_openai_gpt_transformation.py | Adds a pure mock regression test test_chunk_parser_without_id_field that constructs a chunk dict without an id field and asserts no KeyError is raised and an id is auto-generated. No real network calls are made. |
Sequence Diagram
sequenceDiagram
participant Provider as MiniMax / OpenAI-compatible Provider
participant Handler as OpenAIChatCompletionStreamingHandler
participant MRS as ModelResponseStream
Provider->>Handler: Streaming chunk (no 'id' field)
Note over Handler: chunk.get("id") → None<br/>(was chunk["id"] → KeyError)
Handler->>MRS: ModelResponseStream(id=None, ...)
Note over MRS: id is None → _generate_id()
MRS-->>Handler: ModelResponseStream(id="chatcmpl-<generated>", ...)
Handler-->>Provider: Parsed chunk with auto-generated id
Last reviewed commit: "fix(openai): handle ..."
Contributor
RheagalFire
approved these changes
Mar 19, 2026
RheagalFire
changed the base branch from
main
to
litellm_oss_staging_03_19_2026
March 19, 2026 07:34
RheagalFire
merged commit Mar 19, 2026
b20c448
into
BerriAI:litellm_oss_staging_03_19_2026
17 of 39 checks passed
fzowl
pushed a commit
to fzowl/litellm
that referenced
this pull request
Jun 24, 2026
BerriAI#23931) - Change chunk["id"] to chunk.get("id") for compatibility with MiniMax - ModelResponseStream auto-generates id when None is passed - Add regression test test_chunk_parser_without_id_field
4 tasks
yassin-berriai
added a commit
that referenced
this pull request
Jul 6, 2026
…treams (#32237) * fix(streaming): surface in-body error payloads on OpenAI-compatible streams vLLM and sglang return HTTP 200 streams whose SSE body carries the error, e.g. data: {"error": {"message": "...", "code": 400}}. The OpenAI-compatible chunk parser had no detection for this shape: since #23931 the payload parsed into an empty chunk (choices=[]) and the stream ended silently with 200, losing the provider's error and never attempting configured fallbacks. Detect the payload in OpenAIChatCompletionStreamingHandler.chunk_parser and raise OpenAIError with the upstream message and status code. The existing mid-stream gate then applies: 4xx surface directly to the client, 5xx wrap into MidStreamFallbackError so the router can run configured fallbacks. Fixes #25492 * fix(streaming): serialize messageless error payloads as JSON Address review feedback: an error dict without a message field now serializes via json.dumps instead of Python dict repr
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.
Relevant issues
Fixes KeyError: 'id' when using MiniMax m2.5 model with streaming responses
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/test_litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
CI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Type
🐛 Bug Fix
✅ Test
Changes
Problem
When using MiniMax m2.5 model (or other OpenAI-compatible providers), streaming responses may include chunks without an
idfield. The code atgpt_transformation.py:809usedchunk["id"]which throwsKeyError: 'id'when the field is missing.Solution
chunk["id"]tochunk.get("id")inlitellm/llms/openai/chat/gpt_transformation.pyidisNone,ModelResponseStreamautomatically generates one via_generate_id()Files Changed
litellm/llms/openai/chat/gpt_transformation.py- Fix KeyError by using safe dict accesstests/test_litellm/llms/openai/chat/test_openai_gpt_transformation.py- Add regression test