diff --git a/CHANGELOG.md b/CHANGELOG.md index 98a95c3..d84c6fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,13 +28,20 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ------ ## [1.0.1](https://github.com/asfadmin/Discovery-SearchAPI-v3/compare/v1.0.0...v1.0.1) +### Fixed +- Generic searches (non-search related params) no longer accepted, raise 400 +- Fixed string comparison of numbers in range filters + +### Changed +- Include wkt in error when raising in `validate_wkt()` + ### Added - Add dedicated dev branch for test-staging deployment - Intended Dev->Release workflow - dev -> test -> prod-staging -> prod ### Changed -- pin `asf-search` to v8.2.3, All basic Vertex dataset searches working +- pin `asf-search` to v8.3.0, All basic Vertex dataset searches working ## [1.0.0](https://github.com/asfadmin/Discovery-SearchAPI-v3/compare/v0.1.0...v1.0.0) diff --git a/requirements.txt b/requirements.txt index 8aacbdc..f1aa76c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,10 +22,10 @@ ujson==5.7.0 uvicorn==0.21.1 watchfiles==0.19.0 -asf_search==8.2.3 +asf_search==8.3.0 python-json-logger==2.0.7 -pyshp +pyshp==2.1.3 geopandas geomet kml2geojson diff --git a/src/SearchAPI/application/application.py b/src/SearchAPI/application/application.py index 30195e8..9744e6c 100644 --- a/src/SearchAPI/application/application.py +++ b/src/SearchAPI/application/application.py @@ -42,6 +42,17 @@ async def query_params(searchOptions: SearchOptsModel = Depends(process_search_r output = searchOptions.output opts = searchOptions.opts + non_search_param = ['output', 'maxresults', 'pagesize', 'maturity'] + try: + any_searchables = any([key.lower() not in non_search_param for key, _ in opts]) + if not any_searchables: + raise ValueError( + 'No searchable parameters specified, queries must include' + ' parameters besides output= and maxresults=' + ) + except ValueError as exc: + raise HTTPException(detail=repr(exc), status_code=400) from exc + if output.lower() == 'count': start = time.perf_counter() count=asf.search_count(opts=opts) @@ -222,7 +233,7 @@ def validate_wkt(wkt: str): wrapped, unwrapped, reports = asf.validate_wkt(wkt) repairs = [{'type': report.report_type, 'report': report.report} for report in reports if report.report_type != "'type': 'WRAP'"] except Exception as exc: - raise HTTPException(detail=f"Failed to validate wkt: {exc}", status_code=400) from exc + raise HTTPException(detail=f"Failed to validate wkt {wkt}: {exc}", status_code=400) from exc return { 'wkt': { diff --git a/src/SearchAPI/application/asf_opts.py b/src/SearchAPI/application/asf_opts.py index 6647e5b..1ca9515 100644 --- a/src/SearchAPI/application/asf_opts.py +++ b/src/SearchAPI/application/asf_opts.py @@ -13,6 +13,7 @@ from .logger import api_logger +non_search_param = ['output', 'maxresults', 'pagesize', 'maturity'] def string_to_range(v: Union[str, list]) -> tuple: if isinstance(v, list): @@ -23,7 +24,7 @@ def string_to_range(v: Union[str, list]) -> tuple: if m is None: raise ValueError(f'Invalid range: {v}') a = (m.group(1), m.group(3)) - if a[0] > a[1]: + if float(a[0]) > float(a[1]): raise ValueError() if a[0] == a[1]: a = a[0]