[Bugfix] Properly reject requests with empty list guided_choice (#20195)

Signed-off-by: mgoin <mgoin64@gmail.com>
This commit is contained in:
Michael Goin 2025-06-28 14:50:52 +09:00 committed by GitHub
parent d45417b804
commit f719772281
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -173,6 +173,12 @@ class Processor:
params.guided_decoding.backend = engine_level_backend
# Request content validation
if (isinstance(params.guided_decoding.choice, list)
and not params.guided_decoding.choice):
# It is invalid for choice to be an empty list
raise ValueError(f"Choice '{params.guided_decoding.choice}' "
"cannot be an empty list")
if engine_level_backend.startswith("xgrammar"):
# xgrammar with no fallback
validate_xgrammar_grammar(params)