fix(frontend): return 400 for missing completions json_schema (#28090)

Signed-off-by: Ting Sun <suntcrick@gmail.com>
This commit is contained in:
Ting SUN
2026-06-22 15:47:05 -07:00
committed by GitHub
parent 6c212a5d6b
commit e00703bb2a
2 changed files with 18 additions and 3 deletions
@@ -140,6 +140,17 @@ class ServingCompletionTestCase(unittest.TestCase):
self.assertIn("json_schema", sampling_params)
self.assertIsInstance(sampling_params["json_schema"], str)
def test_response_format_json_schema_missing_schema(self):
"""Test that json_schema response_format without a schema raises a ValueError."""
req = CompletionRequest(
model="x",
prompt="Generate a JSON object:",
max_tokens=100,
response_format={"type": "json_schema"},
)
with self.assertRaises(ValueError):
self.sc._build_sampling_params(req)
def test_response_format_structural_tag(self):
"""Test that response_format structural_tag is correctly processed in sampling params."""
req = CompletionRequest(