This commit is contained in:
@@ -233,6 +233,13 @@ class CDEKClient:
|
||||
url,
|
||||
failure_message="CDEK get order failed",
|
||||
)
|
||||
requests_with_errors = _extract_requests_with_errors(raw_payload)
|
||||
if requests_with_errors:
|
||||
log.warning(
|
||||
"cdek_order_request_errors",
|
||||
cdek_order_uuid=cdek_order_uuid,
|
||||
requests=requests_with_errors,
|
||||
)
|
||||
try:
|
||||
return map_cdek_order_info_response(raw_payload)
|
||||
except CDEKOrderMappingError as exc:
|
||||
@@ -513,3 +520,28 @@ def _response_text_or_none(response: httpx.Response) -> str | None:
|
||||
return response.text
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
def _extract_requests_with_errors(
|
||||
payload: dict[str, Any],
|
||||
) -> list[dict[str, object]]:
|
||||
requests = payload.get("requests")
|
||||
if not isinstance(requests, list):
|
||||
return []
|
||||
|
||||
requests_with_errors: list[dict[str, object]] = []
|
||||
for request in requests:
|
||||
if not isinstance(request, dict):
|
||||
continue
|
||||
errors = request.get("errors")
|
||||
if not isinstance(errors, list) or not errors:
|
||||
continue
|
||||
requests_with_errors.append(
|
||||
{
|
||||
"request_uuid": request.get("request_uuid"),
|
||||
"type": request.get("type"),
|
||||
"state": request.get("state"),
|
||||
"errors": errors,
|
||||
}
|
||||
)
|
||||
return requests_with_errors
|
||||
|
||||
Reference in New Issue
Block a user