From 3225973c86c615b6ade83cd7b9e85e30009da374 Mon Sep 17 00:00:00 2001 From: Ariana Barzinpour Date: Tue, 2 Jul 2024 05:47:35 +0000 Subject: [PATCH] add error handling for query extension --- cubedash/_stac.py | 7 +++++++ integration_tests/test_stac.py | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/cubedash/_stac.py b/cubedash/_stac.py index 1ba28c2b3..f3f5ad648 100644 --- a/cubedash/_stac.py +++ b/cubedash/_stac.py @@ -559,6 +559,13 @@ def _handle_search_request( "Only 'id', 'collection', and Item properties can be used to sort results.", ) + # Make sure users know that the query extension isn't implemented + if request_args.get("query") is not None: + abort( + 400, + "The Query extension is no longer supported. Please use the Filter extension instead.", + ) + filter_lang = request_args.get("filter-lang", default=None, type=str) filter_cql = request_args.get("filter", default=None, type=_filter_arg) filter_crs = request_args.get("filter-crs", default=None) diff --git a/integration_tests/test_stac.py b/integration_tests/test_stac.py index daaa36e0f..9cb1a4331 100644 --- a/integration_tests/test_stac.py +++ b/integration_tests/test_stac.py @@ -1540,3 +1540,22 @@ def test_stac_filter_extension(stac_client: FlaskClient): headers={"Content-Type": "application/json", "Accept": "application/json"}, ) assert rv.status_code == 400 + + +def test_stac_query_extension_errors(stac_client: FlaskClient): + # Trying to use query extension should error + query = {"cloud_cover": {"lt": 1}} + rv: Response = stac_client.post( + "/stac/search", + data=json.dumps( + { + "product": "ga_ls8c_ard_3", + "time": "2022-01-01T00:00:00/2022-12-31T00:00:00", + "limit": OUR_DATASET_LIMIT, + "_full": True, + "query": query, + } + ), + headers={"Content-Type": "application/json", "Accept": "application/json"}, + ) + assert rv.status_code == 400