pgstac's database level hydration drops "datetime": null from STAC item properties when reconstructing items for API responses. This produces invalid STAC items when start_datetime/end_datetime are used, because the STAC spec requires "datetime": null to be explicitly present in that case.
Reproduction
1. Ingest an item with datetime: null
Ingest any STAC item that uses a date range (i.e., datetime is null with start_datetime and end_datetime set).
2. Query the item back via the search function
SELECT content_hydrate(items) FROM items WHERE id = '<your-item-id>';
Or via stac-fastapi-pgstac:
curl -s 'http://localhost:8081/collections/<collection>/items?limit=1' | python3 -c "
import json, sys
data = json.load(sys.stdin)
print(json.dumps(data['features'][0]['properties'], indent=2))
"
3. Observe that datetime is missing
Expected:
{
"datetime": null,
"start_datetime": "2024-01-01T00:00:00Z",
"end_datetime": "2024-01-02T00:00:00Z"
}
Actual:
{
"start_datetime": "2024-01-01T00:00:00Z",
"end_datetime": "2024-01-02T00:00:00Z"
}
"datetime" is entirely absent from the response, not just null.
pgstac's database level hydration drops
"datetime": nullfrom STAC item properties when reconstructing items for API responses. This produces invalid STAC items whenstart_datetime/end_datetimeare used, because the STAC spec requires"datetime": nullto be explicitly present in that case.Reproduction
1. Ingest an item with
datetime: nullIngest any STAC item that uses a date range (i.e.,
datetimeisnullwithstart_datetimeandend_datetimeset).2. Query the item back via the search function
Or via stac-fastapi-pgstac:
3. Observe that
datetimeis missingExpected:
{ "datetime": null, "start_datetime": "2024-01-01T00:00:00Z", "end_datetime": "2024-01-02T00:00:00Z" }Actual:
{ "start_datetime": "2024-01-01T00:00:00Z", "end_datetime": "2024-01-02T00:00:00Z" }"datetime"is entirely absent from the response, not just null.