Repository navigation
fix(serve): reject unsupported chat content blocks - #5047
Open
silencelamb wants to merge 1 commit into
Open
silencelamb wants to merge 1 commit into
silencelamb wants to merge 1 commit into
Conversation
4 tasks done
silencelamb
requested review from
CUHKSZzxy,
caikun-pjlab and
yidingcheng0206
October 20, 2026 23:09
silencelamb
force-pushed
the
fix/chat-content-validation
branch
from
October 20, 2026 23:15
b49ceef to
66a519f
Compare
This branch has not been deployed
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.
Motivation
A Chat request containing only an unknown content block, such as
{"role": "user", "content": [{"type": "unsupported_probe"}]}, returns HTTP 200 in both streaming and non-streaming modes. Multimodal detection ignores the block, and text preprocessing then silently removes it.Reject unsupported blocks with their message/content indexes before template rendering, media loading, or generation.
Modification
ValueErrorthat the existing engine error handling maps to HTTP 400. Error messages identify locations such asmessages[1].content[0].type.BC-breaking (Optional)
Malformed or unsupported Chat blocks that were previously silently discarded now return HTTP 400, including for
stream=true. The shared processor also rejects these blocks for direct Python callers. Supported text/media inputs and Anthropic extension-block handling retain their behavior.Use cases (Optional)
For an unknown block at the second position of the second message, the error message is:
Streaming requests receive the JSON error before an SSE stream starts.
Validation
AsyncEngine.preprocessandMultimodalProcessorwith simulated generation.66a519fc, 538 tests passed:python -m pytest tests/test_lmdeploy/serve tests/test_lmdeploy/test_content_merge.py -q(2026-10-21). Applicable pre-commit hooks also passed on this revision.git diff --checkpassed.Fresh real-model validation on 2026-10-20: the local integration with #5043, #5044, and #5046 at
501c5899passed 106/106 serial HTTP cases against GLM-5.3-Flash on 8 H200 GPUs (PyTorch TP8, MP executor, eager mode, batch size 2, session length 8192, no MTP). The request fixtures and expectations are identical to the earlier 104/106 run except for the served model alias.messages[0].content[0].type; no SSE stream is opened.The temporary GPU service and Router were stopped after validation.
Dependency and review scope
This fix is based directly on upstream
mainat52e57d8f, which includes merged #5043. The rebase preserves that PR's image-aware Responses converter and error locations unchanged; the overlapping Responses production-code change is no longer part of this diff. This PR does not depend on the pending #5044 or #5046. The real-model results above were obtained on the explicitly identified earlier integration revision; the current rebase was validated with CPU automated tests.Checklist