@@ -393,7 +393,7 @@ def format_dict(field: dict):
393393 raise ValueError
394394 except ValueError as exc :
395395 raise log_http_exception (
396- status_code = status .HTTP_422_UNPROCESSABLE_ENTITY ,
396+ status_code = status .HTTP_422_UNPROCESSABLE_CONTENT ,
397397 detail = f"Invalid page value: { page !r} " ,
398398 ) from exc
399399
@@ -406,7 +406,7 @@ def format_dict(field: dict):
406406 raise ValueError
407407 except ValueError as exc :
408408 raise log_http_exception (
409- status_code = status .HTTP_422_UNPROCESSABLE_ENTITY ,
409+ status_code = status .HTTP_422_UNPROCESSABLE_CONTENT ,
410410 detail = f"Invalid limit value: { limit !r} " ,
411411 ) from exc
412412
@@ -421,7 +421,7 @@ def format_dict(field: dict):
421421 elif isinstance (sortby_param , list ):
422422 if len (sortby_param ) > 1 :
423423 raise log_http_exception (
424- status .HTTP_422_UNPROCESSABLE_ENTITY ,
424+ status .HTTP_422_UNPROCESSABLE_CONTENT ,
425425 f"Only one 'sortby' search parameter is allowed: { sortby_param !r} " ,
426426 )
427427 if sortby_param :
@@ -440,7 +440,7 @@ def format_dict(field: dict):
440440 stac_params ["published" ] = datetime
441441 except HTTPException as exception :
442442 raise log_http_exception (
443- status .HTTP_422_UNPROCESSABLE_ENTITY ,
443+ status .HTTP_422_UNPROCESSABLE_CONTENT ,
444444 f"Invalid datetime interval: { datetime !r} . "
445445 "Expected format is either: 'YYYY-MM-DDThh:mm:ssZ', 'YYYY-MM-DDThh:mm:ssZ/YYYY-MM-DDThh:mm:ssZ', "
446446 "'YYYY-MM-DDThh:mm:ssZ/..' or '../YYYY-MM-DDThh:mm:ssZ'" ,
@@ -457,7 +457,7 @@ def read_property(prop: str, value: Any):
457457 nonlocal stac_params # noqa: F824
458458 if prop not in allowed_properties :
459459 raise log_http_exception (
460- status .HTTP_422_UNPROCESSABLE_ENTITY ,
460+ status .HTTP_422_UNPROCESSABLE_CONTENT ,
461461 f"Invalid query or CQL property: { prop !r} , " f"allowed properties are: { allowed_properties } " ,
462462 )
463463 if isinstance (value , dict ):
@@ -488,7 +488,7 @@ def read_cql(filt: dict):
488488 if op and op .lower () == "intersects" :
489489 if len (args ) != 2 :
490490 raise log_http_exception (
491- status .HTTP_422_UNPROCESSABLE_ENTITY ,
491+ status .HTTP_422_UNPROCESSABLE_CONTENT ,
492492 f"Invalid intersects: { format_dict (filt )} " ,
493493 )
494494 geom = args [1 ]
@@ -504,7 +504,7 @@ def read_cql(filt: dict):
504504 if op == "=" :
505505 if (len (args ) != 2 ) or not (prop := args [0 ].get ("property" )):
506506 raise log_http_exception (
507- status .HTTP_422_UNPROCESSABLE_ENTITY ,
507+ status .HTTP_422_UNPROCESSABLE_CONTENT ,
508508 f"Invalid CQL2 filter: { format_dict (filt )} " ,
509509 )
510510 value = args [1 ]
@@ -521,7 +521,7 @@ def read_cql(filt: dict):
521521 # Else we are reading several properties
522522 if op != "and" :
523523 raise log_http_exception (
524- status .HTTP_422_UNPROCESSABLE_ENTITY ,
524+ status .HTTP_422_UNPROCESSABLE_CONTENT ,
525525 f"Invalid CQL2 filter, only '=', 'and' and temporal operators are allowed, got '{ op } ': { format_dict (filt )} " , # noqa: E501 # pylint: disable=line-too-long
526526 )
527527 for sub_filter in args :
@@ -544,7 +544,7 @@ def read_query(query_arg: str | None):
544544 # Extract prop and check if it's in the queryables.
545545 if (prop := kv [0 ].strip ()) not in allowed_properties :
546546 raise log_http_exception (
547- status .HTTP_422_UNPROCESSABLE_ENTITY ,
547+ status .HTTP_422_UNPROCESSABLE_CONTENT ,
548548 f"Invalid query filter property: { prop !r} , allowed properties are: { allowed_properties } " ,
549549 )
550550 value = str (kv [1 ]).strip ("'\" " )
@@ -561,7 +561,7 @@ def read_query(query_arg: str | None):
561561 logger .debug (f"Temporal operator detected: { op } -> { stac_params [op ]} " )
562562 else :
563563 raise log_http_exception (
564- status .HTTP_422_UNPROCESSABLE_ENTITY ,
564+ status .HTTP_422_UNPROCESSABLE_CONTENT ,
565565 "Invalid query filter, only '=' and temporal operators are allowed, got: " + query_arg ,
566566 )
567567
@@ -572,7 +572,7 @@ def read_query(query_arg: str | None):
572572 for prop , operator in query .items ():
573573 if (len (operator ) != 1 ) or not (value := operator .get ("eq" )):
574574 raise log_http_exception (
575- status .HTTP_422_UNPROCESSABLE_ENTITY ,
575+ status .HTTP_422_UNPROCESSABLE_CONTENT ,
576576 f"Invalid query: {{{ prop !r} : { format_dict (operator )} }}"
577577 ", only {'<property>': {'eq': <value>}} is allowed" ,
578578 )
@@ -599,7 +599,7 @@ def read_query(query_arg: str | None):
599599 # If search parameters remain, they are not implemented
600600 if params :
601601 raise log_http_exception (
602- status .HTTP_422_UNPROCESSABLE_ENTITY ,
602+ status .HTTP_422_UNPROCESSABLE_CONTENT ,
603603 f"Unimplemented search parameters: { format_dict (params )} " ,
604604 )
605605
@@ -1056,7 +1056,7 @@ def create_collection(collection: dict) -> stac_pydantic.Collection:
10561056 except ValidationError as exc :
10571057 raise log_http_exception (
10581058 detail = f"Unable to create stac_pydantic.Collection, { repr (exc .errors ())} " ,
1059- status_code = status .HTTP_422_UNPROCESSABLE_ENTITY ,
1059+ status_code = status .HTTP_422_UNPROCESSABLE_CONTENT ,
10601060 ) from exc
10611061
10621062
@@ -1073,13 +1073,13 @@ def wrapping_logic(*_args, **_kwargs):
10731073 except KeyError as exc :
10741074 logger .error (f"KeyError caught in { func .__name__ } " )
10751075 raise log_http_exception (
1076- status_code = status .HTTP_422_UNPROCESSABLE_ENTITY ,
1076+ status_code = status .HTTP_422_UNPROCESSABLE_CONTENT ,
10771077 detail = f"Cannot create STAC Collection -> Missing { exc } " ,
10781078 ) from exc
10791079 except ValidationError as exc :
10801080 logger .error (f"ValidationError caught in { func .__name__ } " )
10811081 raise log_http_exception (
1082- status_code = status .HTTP_422_UNPROCESSABLE_ENTITY ,
1082+ status_code = status .HTTP_422_UNPROCESSABLE_CONTENT ,
10831083 detail = f"Parameters validation error: { exc } " ,
10841084 ) from exc
10851085
@@ -1149,7 +1149,7 @@ def filter_allowed_collections(all_collections: list[dict], role: ServiceRole |
11491149
11501150 # If a collection is incomplete in the configuration file, log the error and proceed
11511151 except HTTPException as exception :
1152- if exception .status_code == status .HTTP_422_UNPROCESSABLE_ENTITY :
1152+ if exception .status_code == status .HTTP_422_UNPROCESSABLE_CONTENT :
11531153 logger .error (exception )
11541154 else :
11551155 raise
@@ -1251,7 +1251,7 @@ def get_sort_key(item):
12511251 sorted_items = sorted (item_collection .features , key = get_sort_key , reverse = direction == "-" )
12521252 except AttributeError as e :
12531253 raise log_http_exception (
1254- status_code = status .HTTP_422_UNPROCESSABLE_ENTITY ,
1254+ status_code = status .HTTP_422_UNPROCESSABLE_CONTENT ,
12551255 detail = f"Invalid attribute '{ attribute } ' for sorting: { str (e )} ," ,
12561256 ) from e
12571257 return ItemCollection (features = sorted_items , type = item_collection .type )
@@ -1271,7 +1271,7 @@ def check_input_type(field_info, key, input_value):
12711271
12721272 if not type_mapping .get (expected_type )(input_value ): # type: ignore
12731273 raise log_http_exception (
1274- status .HTTP_422_UNPROCESSABLE_ENTITY ,
1274+ status .HTTP_422_UNPROCESSABLE_CONTENT ,
12751275 "Invalid CQL2 filter value" ,
12761276 )
12771277
0 commit comments