Unverified Commit 0f19427d authored by 7. Sun's avatar 7. Sun Committed by GitHub
Browse files

[Perf] Cache exc.errors() result in validation exception handler (#32984)


Signed-off-by: default avatar7. Sun <jhao.sun@gmail.com>
parent 51931c5c
...@@ -558,7 +558,8 @@ def build_app(args: Namespace) -> FastAPI: ...@@ -558,7 +558,8 @@ def build_app(args: Namespace) -> FastAPI:
@app.exception_handler(RequestValidationError) @app.exception_handler(RequestValidationError)
async def validation_exception_handler(_: Request, exc: RequestValidationError): async def validation_exception_handler(_: Request, exc: RequestValidationError):
param = None param = None
for error in exc.errors(): errors = exc.errors()
for error in errors:
if "ctx" in error and "error" in error["ctx"]: if "ctx" in error and "error" in error["ctx"]:
ctx_error = error["ctx"]["error"] ctx_error = error["ctx"]["error"]
if isinstance(ctx_error, VLLMValidationError): if isinstance(ctx_error, VLLMValidationError):
...@@ -566,9 +567,9 @@ def build_app(args: Namespace) -> FastAPI: ...@@ -566,9 +567,9 @@ def build_app(args: Namespace) -> FastAPI:
break break
exc_str = str(exc) 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}" message = f"{exc_str} {errors_str}"
else: else:
message = exc_str message = exc_str
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment