[Bugfix] Reject NUL byte in structured_outputs.regex (#51796)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Junhao Shen
2026-08-14 00:08:36 +00:00
committed by GitHub
co-authored by Claude Opus 4.8
parent f80b66f548
commit 38f097fab8
3 changed files with 50 additions and 0 deletions
+9
View File
@@ -1029,6 +1029,15 @@ class SamplingParams(
"structured_outputs.json_object must be True if set; omit "
"structured_outputs to disable structured outputs"
)
# Reject a regex containing a NUL byte early, in every backend mode. A
# NUL is never meaningful in a regex pattern and is not handled by the
# regex-to-grammar conversion. Checked here, before backend selection,
# so it is a clean 400 rather than a silent fallback in the default
# "auto" mode.
if self.structured_outputs.regex and "\x00" in self.structured_outputs.regex:
raise VLLMValidationError(
"structured_outputs.regex must not contain a NUL character ('\\x00')"
)
from vllm.v1.structured_output.backend_guidance import (
has_guidance_unsupported_json_features,