Skip to content

Commit 3e9c41d

Browse files
committed
return more information when pydantic raise validation error
1 parent c3b15c7 commit 3e9c41d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
## Changed
1717

1818
* use `stac_pydantic.version.STAC_VERSION` instead of `stac_pydantic.api.version.STAC_API_VERSION` as application `stac_version`
19+
* Return more informations from pydantic validation errors
1920

2021
## [3.0.3] - 2024-10-09
2122

stac_fastapi/api/stac_fastapi/api/errors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import Callable, Dict, Type, TypedDict
55

66
from fastapi import FastAPI
7+
from fastapi.encoders import jsonable_encoder
78
from fastapi.exceptions import RequestValidationError, ResponseValidationError
89
from starlette import status
910
from starlette.requests import Request
@@ -88,7 +89,7 @@ def request_validation_exception_handler(
8889
request: Request, exc: RequestValidationError
8990
) -> JSONResponse:
9091
return JSONResponse(
91-
content=ErrorResponse(code=exc.__class__.__name__, description=str(exc)),
92+
content=jsonable_encoder({"detail": exc.errors(), "body": exc.body}),
9293
status_code=status.HTTP_400_BAD_REQUEST,
9394
)
9495

0 commit comments

Comments
 (0)