[Bugfix] Fall back to Pydantic loc for param in validation errors (#46038)

Signed-off-by: professorsab <135441198+professorsab@users.noreply.github.com>
Co-authored-by: Mahad Durrani <114791389+mahadrehmann@users.noreply.github.com>
This commit is contained in:
Muhammad Fawaz
2026-06-19 19:11:11 +08:00
committed by GitHub
co-authored by Mahad Durrani
parent ec67d7ae61
commit 69bdd34542
2 changed files with 71 additions and 0 deletions
@@ -427,6 +427,12 @@ async def validation_exception_handler(req: Request, exc: RequestValidationError
param = ctx_error.parameter
break
if param is None and errors:
first_error = errors[0]
loc = first_error.get("loc") if isinstance(first_error, dict) else None
if loc:
param = ".".join(str(part) for part in loc)
exc_str = str(exc)
errors_str = str(errors)