Skip to content

Commit 08968fa

Browse files
committed
fix errors when search returns no body
1 parent 9026f28 commit 08968fa

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/stac_api_validator/validations.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3199,23 +3199,24 @@ def validate_item_search_ids(
31993199
r_session=r_session,
32003200
)
32013201

3202-
items = body.get("features") # type: ignore
3203-
if items and len(items) >= 2:
3204-
_validate_search_ids_with_ids(
3205-
search_url, [items[0].get("id")], methods, errors, r_session
3206-
)
3207-
_validate_search_ids_with_ids(
3208-
search_url,
3209-
[items[0].get("id"), items[1].get("id")],
3210-
methods,
3211-
errors,
3212-
r_session,
3213-
)
3214-
_validate_search_ids_with_ids(
3215-
search_url, [i["id"] for i in items], methods, errors, r_session
3216-
)
3217-
else:
3218-
warnings += f"[{Context.ITEM_SEARCH}] GET Search with no parameters returned < 2 results"
3202+
if body:
3203+
items = body.get("features") # type: ignore
3204+
if items and len(items) >= 2:
3205+
_validate_search_ids_with_ids(
3206+
search_url, [items[0].get("id")], methods, errors, r_session
3207+
)
3208+
_validate_search_ids_with_ids(
3209+
search_url,
3210+
[items[0].get("id"), items[1].get("id")],
3211+
methods,
3212+
errors,
3213+
r_session,
3214+
)
3215+
_validate_search_ids_with_ids(
3216+
search_url, [i["id"] for i in items], methods, errors, r_session
3217+
)
3218+
else:
3219+
warnings += f"[{Context.ITEM_SEARCH}] GET Search with no parameters returned < 2 results"
32193220

32203221

32213222
def validate_item_search_ids_does_not_override_all_other_params(
@@ -3236,7 +3237,7 @@ def validate_item_search_ids_does_not_override_all_other_params(
32363237
content_type=geojson_mt,
32373238
r_session=r_session,
32383239
)
3239-
if body.get("features"): # type: ignore
3240+
if body and body.get("features"): # type: ignore
32403241
_validate_search_ids_with_ids_no_override(
32413242
search_url,
32423243
body["features"][0],

0 commit comments

Comments
 (0)