Skip to content

Commit b5544dd

Browse files
committed
Update opensearch collection patch.
1 parent 050254f commit b5544dd

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -988,12 +988,9 @@ async def json_patch_item(
988988
)
989989

990990
except exceptions.BadRequestError as exc:
991-
detail = (
992-
exc.info["error"]["caused_by"]["to_string"]
993-
if "to_string" in exc.info["error"]["caused_by"]
994-
else exc.info["error"]["caused_by"]
995-
)
996-
raise HTTPException(status_code=400, detail=detail) from exc
991+
raise HTTPException(
992+
status_code=400, detail=exc.info["error"]["caused_by"]
993+
) from exc
997994

998995
item = await self.get_one_item(collection_id, item_id)
999996

@@ -1228,12 +1225,9 @@ async def json_patch_collection(
12281225
)
12291226

12301227
except exceptions.BadRequestError as exc:
1231-
detail = (
1232-
exc.info["error"]["caused_by"]["to_string"]
1233-
if "to_string" in exc.info["error"]["caused_by"]
1234-
else exc.info["error"]["caused_by"]
1235-
)
1236-
raise HTTPException(status_code=400, detail=detail) from exc
1228+
raise HTTPException(
1229+
status_code=400, detail=exc.info["error"]["caused_by"]
1230+
) from exc
12371231

12381232
collection = await self.find_collection(collection_id)
12391233

stac_fastapi/opensearch/stac_fastapi/opensearch/database_logic.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ async def json_patch_item(
10211021

10221022
except exceptions.RequestError as exc:
10231023
raise HTTPException(
1024-
status_code=400, detail=exc.info["error"]["caused_by"]["to_string"]
1024+
status_code=400, detail=exc.info["error"]["caused_by"]
10251025
) from exc
10261026

10271027
item = await self.get_one_item(collection_id, item_id)
@@ -1237,8 +1237,8 @@ async def json_patch_collection(
12371237

12381238
for operation in operations:
12391239
if (
1240-
operation["op"] in ["add", "replace"]
1241-
and operation["path"] == "collection"
1240+
operation.op in ["add", "replace"]
1241+
and operation.path == "collection"
12421242
and collection_id != operation["value"]
12431243
):
12441244
new_collection_id = operation["value"]
@@ -1252,13 +1252,14 @@ async def json_patch_collection(
12521252
await self.client.update(
12531253
index=COLLECTIONS_INDEX,
12541254
id=collection_id,
1255-
script=script,
1255+
body={"script": script},
12561256
refresh=True,
12571257
)
12581258

12591259
except exceptions.BadRequestError as exc:
1260+
12601261
raise HTTPException(
1261-
status_code=400, detail=exc.info["error"]["caused_by"]["to_string"]
1262+
status_code=400, detail=exc.info["error"]["caused_by"]
12621263
) from exc
12631264

12641265
collection = await self.find_collection(collection_id)

0 commit comments

Comments
 (0)