-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API doesn't allow adding an Item to a Collection if geometry
field is missing or null
#169
Comments
☝️ edited, in fact you need a BBOX only when the geometry is not Null For the second error, this would need to be checked with pgstac directly but yeah it might be possible that it doesn't support empty geometries |
Hi @vincentsarago, thanks for your fast reply.
In fact I obtain the same errors if the |
Anyway, from a FastAPI perspective I can see that the issue is due to the fact that the
Also, on the postgres side I can see that So it does look like a deliberate choice, but in this case I would like to know why it looks (at least to my knowledge) in contrast with the STAC specification. |
The body request is defined in https://github.com/stac-utils/stac-fastapi/blob/4491fa1ee384cd3e789e30aaa1252cdbb2ea3246/stac_fastapi/extensions/stac_fastapi/extensions/core/transaction.py#L19-L23 so it uses the stac-pydantic definition and is then transformed to a dict (but that would not throw any error), I'm pretty sure the geometry can be null, so I'm not sure where your error comes from. from stac_pydantic import Item
from stac_fastapi.types import stac as stac_types
item_dict = {
"id": "f2cca2a3-288b-4518-8a3e-a4492bb60b08",
"type": "Feature",
"geometry": None,
"collection": "joplin",
"links": [],
"properties": {
"datetime": "2000-02-02T00:00:00Z"
},
"assets": {},
"stac_extensions": [],
"stac_version": "1.0.0"
}
item = Item.model_validate(item_dict)
>> Item(bbox=None, type='Feature', geometry=None, properties=ItemProperties(title=None, description=None, datetime=datetime.datetime(2000, 2, 2, 0, 0, tzinfo=datetime.timezone.utc), created=None, updated=None, start_datetime=None, end_datetime=None, license=None, providers=None, platform=None, instruments=None, constellation=None, mission=None, gsd=None), id='f2cca2a3-288b-4518-8a3e-a4492bb60b08', stac_version='1.0.0', assets={}, links=Links(root=[]), stac_extensions=[], collection='joplin')
item = item.model_dump(mode="json")
stac_types.Item(**item)
>> {'type': 'Feature', 'geometry': None, 'properties': {'datetime': '2000-02-02T00:00:00Z'}, 'id': 'f2cca2a3-288b-4518-8a3e-a4492bb60b08', 'stac_version': '1.0.0', 'assets': {}, 'links': [], 'stac_extensions': [], 'collection': 'joplin'} Which version of stac-fastapi are you using?
Yeah, let's consider this another issue at the moment |
Geometry is required to be not null in pgstac. |
These is the output of
|
Hi @bitner, thanks. So it is a choice which doesn't comply with the standard, correct? |
Description
When trying to submit a
POST /collections/{collection_id}/items
request the following behaviors occur:geometry
field is missing, I get a400
response associated to aRequestValidationError
stating that thegeometry
field is required;geometry
field is null, I get a424
response associated to aDatabaseError
, which appears to be caused by the fact that thegeometry
column in the postgres datbase is not nullable;Expected behavior
The STAC Item specification for the
geometry
field states thatI would thus expect it to be possible to at least create an Item with the
geometry
property set tonull
.How to replicate
After cloning the repository, in its root directory launch
Then
which results in
Also, try
which results in
The text was updated successfully, but these errors were encountered: