From 9a21e331ff8c4ab052a654b3ebd9f67ddfff4845 Mon Sep 17 00:00:00 2001 From: Guillaume Calmettes Date: Wed, 28 May 2025 05:35:43 +0200 Subject: [PATCH] [Bugfix]: correctly propagate errors message caught at the chat_templating step to the client (#18769) Signed-off-by: Guillaume Calmettes --- vllm/entrypoints/chat_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vllm/entrypoints/chat_utils.py b/vllm/entrypoints/chat_utils.py index ec1b327da9058..b051cd3338a4c 100644 --- a/vllm/entrypoints/chat_utils.py +++ b/vllm/entrypoints/chat_utils.py @@ -1252,7 +1252,7 @@ def apply_hf_chat_template( # investigation. logger.exception( "An error occurred in `transformers` while applying chat template") - raise ValueError from e + raise ValueError(str(e)) from e def apply_mistral_chat_template( tokenizer: MistralTokenizer, @@ -1281,7 +1281,7 @@ def apply_mistral_chat_template( # We convert those assertion errors to ValueErrors so they can be # are properly caught in the preprocessing_input step except (AssertionError, MistralCommonException) as e: - raise ValueError from e + raise ValueError(str(e)) from e # External library exceptions can sometimes occur despite the framework's # internal exception management capabilities. @@ -1292,7 +1292,7 @@ def apply_mistral_chat_template( logger.exception( "An error occurred in `mistral_common` while applying chat " "template") - raise ValueError from e + raise ValueError(str(e)) from e def random_tool_call_id() -> str: return f"chatcmpl-tool-{random_uuid()}"