A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 7, 19:00 UTC
[Responses][CI] Filter negative token IDs in schema fuzz test to avoid 500 errors (#35231)
Signed-off-by: Andreas Karatzas <akaratza@amd.com>
Andreas Karatzas committed
Feb 24, 2026 at 23:52 UTC
2ff3e436ade14b005abe6423752966319c365eb2
2 files changed
+27
-1
tests/entrypoints/openai/test_completion_error.py
+20
@@ -219,3 +219,23 @@ async def test_completion_error_stream():
219
f"Expected error message in chunks: {chunks}"
220
)
221
assert chunks[-1] == "data: [DONE]\n\n"
222
+
223
+
224
+def test_negative_prompt_token_ids_nested():
225
+ """Negative token IDs in prompt (nested list) should raise validation error."""
226
+ with pytest.raises(Exception, match="greater than or equal to 0"):
227
+ CompletionRequest(
228
+ model=MODEL_NAME,
229
+ prompt=[[-1]],
230
+ max_tokens=10,
231
+ )
232
+
233
+
234
+def test_negative_prompt_token_ids_flat():
235
+ """Negative token IDs in prompt (flat list) should raise validation error."""
236
+ with pytest.raises(Exception, match="greater than or equal to 0"):
237
+ CompletionRequest(
238
+ model=MODEL_NAME,
239
+ prompt=[-1],
240
+ max_tokens=10,
241
+ )
vllm/entrypoints/openai/completion/protocol.py
+7
-1
@@ -42,7 +42,13 @@ class CompletionRequest(OpenAIBaseModel):
42
# Ordered by official OpenAI API documentation
43
# https://platform.openai.com/docs/api-reference/completions/create
44
model: str | None = None
45
- prompt: list[int] | list[list[int]] | str | list[str] | None = None
45
+ prompt: (
46
+ list[Annotated[int, Field(ge=0)]]
47
+ | list[list[Annotated[int, Field(ge=0)]]]
48
+ | str
49
+ | list[str]
50
+ | None
51
+ ) = None
52
echo: bool | None = False
53
frequency_penalty: float | None = 0.0
54
logit_bias: dict[str, float] | None = None