Skip to content

Commit

Permalink
return more information when pydantic raise validation error (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago authored Jan 7, 2025
1 parent c3b15c7 commit d2eb81d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
## Changed

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

## [3.0.3] - 2024-10-09

Expand Down
3 changes: 2 additions & 1 deletion stac_fastapi/api/stac_fastapi/api/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Callable, Dict, Type, TypedDict

from fastapi import FastAPI
from fastapi.encoders import jsonable_encoder
from fastapi.exceptions import RequestValidationError, ResponseValidationError
from starlette import status
from starlette.requests import Request
Expand Down Expand Up @@ -88,7 +89,7 @@ def request_validation_exception_handler(
request: Request, exc: RequestValidationError
) -> JSONResponse:
return JSONResponse(
content=ErrorResponse(code=exc.__class__.__name__, description=str(exc)),
content=jsonable_encoder({"detail": exc.errors(), "body": exc.body}),
status_code=status.HTTP_400_BAD_REQUEST,
)

Expand Down

0 comments on commit d2eb81d

Please sign in to comment.