Skip to content

Commit

Permalink
fix errors when search returns no body
Browse files Browse the repository at this point in the history
  • Loading branch information
vprivat-ads committed Nov 29, 2024
1 parent 9026f28 commit 08968fa
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/stac_api_validator/validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3199,23 +3199,24 @@ def validate_item_search_ids(
r_session=r_session,
)

items = body.get("features") # type: ignore
if items and len(items) >= 2:
_validate_search_ids_with_ids(
search_url, [items[0].get("id")], methods, errors, r_session
)
_validate_search_ids_with_ids(
search_url,
[items[0].get("id"), items[1].get("id")],
methods,
errors,
r_session,
)
_validate_search_ids_with_ids(
search_url, [i["id"] for i in items], methods, errors, r_session
)
else:
warnings += f"[{Context.ITEM_SEARCH}] GET Search with no parameters returned < 2 results"
if body:
items = body.get("features") # type: ignore
if items and len(items) >= 2:
_validate_search_ids_with_ids(
search_url, [items[0].get("id")], methods, errors, r_session
)
_validate_search_ids_with_ids(
search_url,
[items[0].get("id"), items[1].get("id")],
methods,
errors,
r_session,
)
_validate_search_ids_with_ids(
search_url, [i["id"] for i in items], methods, errors, r_session
)
else:
warnings += f"[{Context.ITEM_SEARCH}] GET Search with no parameters returned < 2 results"


def validate_item_search_ids_does_not_override_all_other_params(
Expand All @@ -3236,7 +3237,7 @@ def validate_item_search_ids_does_not_override_all_other_params(
content_type=geojson_mt,
r_session=r_session,
)
if body.get("features"): # type: ignore
if body and body.get("features"): # type: ignore
_validate_search_ids_with_ids_no_override(
search_url,
body["features"][0],
Expand Down

0 comments on commit 08968fa

Please sign in to comment.