fix(serving_chat): catch TypeError from tojson on Jinja2 Undefined variables (#20700)
This commit is contained in:
@@ -785,8 +785,9 @@ class OpenAIServingChat(OpenAIServingBase):
|
||||
prompt_ids = self.tokenizer_manager.tokenizer.encode(
|
||||
rendered_prompt, **encode_kwargs
|
||||
)
|
||||
except jinja2.TemplateError as template_error:
|
||||
except (jinja2.TemplateError, TypeError) as template_error:
|
||||
# Template errors (e.g., from raise_exception in Jinja templates)
|
||||
# and TypeError (e.g., tojson filter on Jinja2 Undefined variables)
|
||||
# should be treated as client errors (400 BadRequest)
|
||||
raise ValueError(str(template_error)) from template_error
|
||||
|
||||
|
||||
Reference in New Issue
Block a user