File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 4343
4444- add ` write_connection_pool ` option in ` stac_fastapi.pgstac.db.connect_to_db ` function
4545- add ` write_postgres_settings ` option in ` stac_fastapi.pgstac.db.connect_to_db ` function to set specific settings for the ` writer ` DB connection pool
46+ - add specific error message when trying to create ` Item ` with null geometry (not supported by PgSTAC)
4647
4748### removed
4849
Original file line number Diff line number Diff line change @@ -57,6 +57,12 @@ def _validate_item(
5757
5858 self ._validate_id (body_item_id , request .app .state .settings )
5959
60+ if item .get ("geometry" , None ) is None :
61+ raise HTTPException (
62+ status_code = 400 ,
63+ detail = f"Missing or null `geometry` for Item ({ body_item_id } ). Geometry is required in pgstac." ,
64+ )
65+
6066 if body_collection_id is not None and collection_id != body_collection_id :
6167 raise HTTPException (
6268 status_code = 400 ,
Original file line number Diff line number Diff line change @@ -152,6 +152,20 @@ async def test_create_item_bad_body(
152152 assert resp .status_code == 400
153153
154154
155+ async def test_create_item_no_geometry (
156+ app_client , load_test_data : Callable , load_test_collection
157+ ):
158+ """Items with missing or null Geometry should return an error"""
159+ coll = load_test_collection
160+
161+ item = load_test_data ("test_item.json" )
162+ _ = item .pop ("bbox" )
163+ item ["geometry" ] = None
164+ resp = await app_client .post (f"/collections/{ coll ['id' ]} /items" , json = item )
165+ assert resp .status_code == 400
166+ assert "Geometry is required in pgstac." in resp .json ()["detail" ]
167+
168+
155169async def test_update_item (app_client , load_test_collection , load_test_item ):
156170 coll = load_test_collection
157171 item = load_test_item
You can’t perform that action at this time.
0 commit comments