[Bugfix][Structured Outputs] Reject degenerate structured_outputs that crash EngineCore (#45346)

Signed-off-by: Ting Sun <suntcrick@gmail.com>
This commit is contained in:
Ting SUN
2026-06-30 22:41:33 +00:00
committed by GitHub
parent 28242824e0
commit ac521f6237
2 changed files with 33 additions and 0 deletions
+12
View File
@@ -938,6 +938,18 @@ class SamplingParams(
and self.structured_outputs.grammar.strip() == ""
):
raise ValueError("structured_outputs.grammar cannot be an empty string")
# Reject empty string json schema early to avoid engine-side crashes
if (
isinstance(self.structured_outputs.json, str)
and self.structured_outputs.json.strip() == ""
):
raise ValueError("structured_outputs.json cannot be an empty string")
# Reject json_object=False early to avoid engine-side crashes
if self.structured_outputs.json_object is False:
raise ValueError(
"structured_outputs.json_object must be True if set; omit "
"structured_outputs to disable structured outputs"
)
from vllm.v1.structured_output.backend_guidance import (
has_guidance_unsupported_json_features,