Skip to content

Commit

Permalink
fix: don't error when search returns no body (#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
vprivat-ads authored Dec 2, 2024
1 parent d1a3626 commit 248576b
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/stac_api_validator/validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3199,23 +3199,26 @@ 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
)
if not body:
errors += f"[{Context.ITEM_SEARCH}] GET Search body was empty"
else:
warnings += f"[{Context.ITEM_SEARCH}] GET Search with no parameters returned < 2 results"
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 +3239,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 248576b

Please sign in to comment.