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 43
43
44
44
- add ` write_connection_pool ` option in ` stac_fastapi.pgstac.db.connect_to_db ` function
45
45
- 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)
46
47
47
48
### removed
48
49
Original file line number Diff line number Diff line change @@ -57,6 +57,12 @@ def _validate_item(
57
57
58
58
self ._validate_id (body_item_id , request .app .state .settings )
59
59
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
+
60
66
if body_collection_id is not None and collection_id != body_collection_id :
61
67
raise HTTPException (
62
68
status_code = 400 ,
Original file line number Diff line number Diff line change @@ -152,6 +152,20 @@ async def test_create_item_bad_body(
152
152
assert resp .status_code == 400
153
153
154
154
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
+
155
169
async def test_update_item (app_client , load_test_collection , load_test_item ):
156
170
coll = load_test_collection
157
171
item = load_test_item
You can’t perform that action at this time.
0 commit comments