[CI] Stabilize OpenAI schema fuzzing for malformed structural tags (#44131)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
Andreas Karatzas
2026-06-01 19:56:15 -07:00
committed by GitHub
parent 9affc17a05
commit 54d0c36fff
6 changed files with 201 additions and 3 deletions
@@ -30,6 +30,8 @@ from vllm.entrypoints.openai.engine.protocol import (
StructuralTagResponseFormat,
ToolCall,
UsageInfo,
validate_structural_tag_response_format,
validate_structured_outputs_structural_tag,
)
from vllm.exceptions import VLLMValidationError
from vllm.logger import init_logger
@@ -671,6 +673,9 @@ class ChatCompletionRequest(OpenAIBaseModel):
parameter="response_format",
)
if rf_type == "structural_tag":
validate_structural_tag_response_format(response_format)
return data
@model_validator(mode="before")
@@ -754,6 +759,7 @@ class ChatCompletionRequest(OpenAIBaseModel):
"You can only either use constraints for structured outputs "
"or tools, not both.",
)
validate_structured_outputs_structural_tag(structured_outputs_kwargs)
return data
@model_validator(mode="before")
@@ -979,6 +985,16 @@ class BatchChatCompletionRequest(OpenAIBaseModel):
"Batch chat completions do not support beam search. "
"Please set `use_beam_search` to False."
)
response_format = data.get("response_format")
rf_type = (
response_format.get("type")
if isinstance(response_format, dict)
else getattr(response_format, "type", None)
)
if rf_type == "structural_tag":
validate_structural_tag_response_format(response_format)
if (structured_outputs := data.get("structured_outputs")) is not None:
validate_structured_outputs_structural_tag(structured_outputs)
n = data.get("n", 1)
if n is not None and n != 1:
raise ValueError(