File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
stac_fastapi/core/stac_fastapi/core Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -310,7 +310,7 @@ async def item_collection(
310310 Exception: If any error occurs while reading the items from the database.
311311 """
312312 request : Request = kwargs ["request" ]
313- # Ensure the collection exists; otherwise return 404 to match API contract
313+
314314 try :
315315 await self .get_collection (collection_id = collection_id , request = request )
316316 except Exception :
@@ -409,10 +409,18 @@ async def get_search(
409409 base_args ["intersects" ] = orjson .loads (unquote_plus (intersects ))
410410
411411 if sortby :
412- base_args ["sortby" ] = [
413- {"field" : sort [1 :], "direction" : "desc" if sort [0 ] == "-" else "asc" }
414- for sort in sortby
415- ]
412+ parsed_sort = []
413+ for raw in sortby :
414+ if not isinstance (raw , str ):
415+ continue
416+ s = raw .strip ()
417+ if not s :
418+ continue
419+ direction = "desc" if s [0 ] == "-" else "asc"
420+ field = s [1 :] if s and s [0 ] in "+-" else s
421+ parsed_sort .append ({"field" : field , "direction" : direction })
422+ if parsed_sort :
423+ base_args ["sortby" ] = parsed_sort
416424
417425 if filter_expr :
418426 base_args ["filter_lang" ] = "cql2-json"
You can’t perform that action at this time.
0 commit comments