Skip to content

Commit 94c2259

Browse files
committed
Return 400 for Item id or collection conflicts
1 parent a45555f commit 94c2259

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

stac_fastapi/pgstac/stac_fastapi/pgstac/transactions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async def create_item(
3030
body_collection_id = item.get("collection")
3131
if body_collection_id is not None and collection_id != body_collection_id:
3232
raise HTTPException(
33-
status_code=409,
33+
status_code=400,
3434
detail=f"Collection ID from path parameter ({collection_id}) does not match Collection ID from Item ({body_collection_id})",
3535
)
3636
item["collection"] = collection_id
@@ -46,14 +46,14 @@ async def update_item(
4646
body_collection_id = item.get("collection")
4747
if body_collection_id is not None and collection_id != body_collection_id:
4848
raise HTTPException(
49-
status_code=409,
49+
status_code=400,
5050
detail=f"Collection ID from path parameter ({collection_id}) does not match Collection ID from Item ({body_collection_id})",
5151
)
5252
item["collection"] = collection_id
5353
body_item_id = item["id"]
5454
if body_item_id != item_id:
5555
raise HTTPException(
56-
status_code=409,
56+
status_code=400,
5757
detail=f"Item ID from path parameter ({item_id}) does not match Item ID from Item ({body_item_id})",
5858
)
5959
request = kwargs["request"]

stac_fastapi/pgstac/tests/resources/test_item.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async def test_create_item(app_client, load_test_data: Callable, load_test_colle
8686
async def test_create_item_mismatched_collection_id(
8787
app_client, load_test_data: Callable, load_test_collection
8888
):
89-
# If the collection_id path parameter and the Item's "collection" property do not match, a 409 response should
89+
# If the collection_id path parameter and the Item's "collection" property do not match, a 400 response should
9090
# be returned.
9191
coll = load_test_collection
9292

@@ -98,7 +98,7 @@ async def test_create_item_mismatched_collection_id(
9898
f"/collections/{coll.id}/items",
9999
json=in_json,
100100
)
101-
assert resp.status_code == 409
101+
assert resp.status_code == 400
102102

103103

104104
async def test_fetches_valid_item(
@@ -166,7 +166,7 @@ async def test_update_item_mismatched_collection_id(
166166
f"/collections/{coll.id}/items/{item_id}",
167167
json=in_json,
168168
)
169-
assert resp.status_code == 409
169+
assert resp.status_code == 400
170170

171171

172172
async def test_delete_item(

stac_fastapi/sqlalchemy/stac_fastapi/sqlalchemy/transactions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def create_item(
5454
body_collection_id = item.get("collection")
5555
if body_collection_id is not None and collection_id != body_collection_id:
5656
raise HTTPException(
57-
status_code=409,
57+
status_code=400,
5858
detail=f"Collection ID from path parameter ({collection_id}) does not match Collection ID from Item ({body_collection_id})",
5959
)
6060
item["collection"] = collection_id
@@ -80,14 +80,14 @@ def update_item(
8080
body_collection_id = item.get("collection")
8181
if body_collection_id is not None and collection_id != body_collection_id:
8282
raise HTTPException(
83-
status_code=409,
83+
status_code=400,
8484
detail=f"Collection ID from path parameter ({collection_id}) does not match Collection ID from Item ({body_collection_id})",
8585
)
8686
item["collection"] = collection_id
8787
body_item_id = item["id"]
8888
if body_item_id != item_id:
8989
raise HTTPException(
90-
status_code=409,
90+
status_code=400,
9191
detail=f"Item ID from path parameter ({item_id}) does not match Item ID from Item ({body_item_id})",
9292
)
9393
base_url = str(kwargs["request"].base_url)

0 commit comments

Comments
 (0)