From 0f19427db587ae425d62a1857ee3339015ee3084 Mon Sep 17 00:00:00 2001 From: "7. Sun" Date: Sat, 24 Jan 2026 10:01:35 +0000 Subject: [PATCH] [Perf] Cache exc.errors() result in validation exception handler (#32984) Signed-off-by: 7. Sun --- vllm/entrypoints/openai/api_server.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vllm/entrypoints/openai/api_server.py b/vllm/entrypoints/openai/api_server.py index d6b910193c..6de41a9e73 100644 --- a/vllm/entrypoints/openai/api_server.py +++ b/vllm/entrypoints/openai/api_server.py @@ -558,7 +558,8 @@ def build_app(args: Namespace) -> FastAPI: @app.exception_handler(RequestValidationError) async def validation_exception_handler(_: Request, exc: RequestValidationError): param = None - for error in exc.errors(): + errors = exc.errors() + for error in errors: if "ctx" in error and "error" in error["ctx"]: ctx_error = error["ctx"]["error"] if isinstance(ctx_error, VLLMValidationError): @@ -566,9 +567,9 @@ def build_app(args: Namespace) -> FastAPI: break exc_str = str(exc) - errors_str = str(exc.errors()) + errors_str = str(errors) - if exc.errors() and errors_str and errors_str != exc_str: + if errors and errors_str and errors_str != exc_str: message = f"{exc_str} {errors_str}" else: message = exc_str