stac-utils / stac-fastapi

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

Ensure Optional `query` Field Defaults to None for Pydantic V2 Compatibility #700

Closed joshimai closed 1 month ago

joshimai commented 1 month ago

I've identified an issue with the Pydantic model definition in QueryExtensionPostRequest [stac_fastapi.extensions.core.query.request] (https://github.com/stac-utils/stac-fastapi/blob/1c3546a5b449edebc7587dab289f73224847c63e/stac_fastapi/extensions/stac_fastapi/extensions/core/query/request.py#L21). The query field lacks a default value, making it required under Pydantic V2 changes. In Pydantic V2, fields declared as Optional must explicitly default to None to be considered optional and nullable. This change would prevent potential errors from fields being unexpectedly required and aligns with Pydantic V2's migration guidelines.