stac-utils / stac-fastapi

STAC API implementation with FastAPI.
https://stac-utils.github.io/stac-fastapi/
MIT License
246 stars 99 forks source link

Unclear error message for failed response model validation #750

Open drnextgis opened 1 month ago

drnextgis commented 1 month ago

When response model validation is enabled, the API returns an unclear error message that doesn't specify which property failed validation. For example:

{"code":"AttributeError","description":"'int' object has no attribute 'startswith'"}

In this case, the issue was caused by the asset href containing a number instead of a string.

vincentsarago commented 1 month ago

@drnextgis can you be a bit more verbose. which version of stac-fastapi, which backend, which endpoint?

vincentsarago commented 1 month ago

Oh I see, you're saying we should try to make the error message a bit more verbose 😓

I guess https://github.com/stac-utils/stac-fastapi/blob/main/stac_fastapi/api/stac_fastapi/api/errors.py#L49-L97 needs to be updated

drnextgis commented 1 month ago

Exactly, having the name of the property that failed validation would be extremely helpful.