Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Prevent attempts to truncate objects that are not strings (#17067)
Marcin Wcisło57ae915adcef
diff --git a/saleor/webhook/transport/tests/test_utils.py b/saleor/webhook/transport/tests/test_utils.pyindex 1032ce53b9..57626dd5c9 100644--- a/saleor/webhook/transport/tests/test_utils.py+++ b/saleor/webhook/transport/tests/test_utils.py@@ -276,6 +276,7 @@ def test_get_multiple_deliveries_for_webhooks_with_inactive(("error", "error"),("errorerrorerrore", "errorerrorerrore"),(100 * "error", "errorerrorerrore..."),+ (None, None),],)def test_truncate_attempt_response(diff --git a/saleor/webhook/transport/utils.py b/saleor/webhook/transport/utils.pyindex 15541e19de..8db5d96761 100644--- a/saleor/webhook/transport/utils.py+++ b/saleor/webhook/transport/utils.py@@ -468,11 +468,14 @@ def attempt_update(with_save: bool = True,):attempt.duration = webhook_response.duration- attempt.response = webhook_response.content[- : settings.EVENT_DELIVERY_ATTEMPT_RESPONSE_SIZE_LIMIT- ]- if attempt.response != webhook_response.content:- attempt.response += "..."+ if isinstance(webhook_response.content, str):+ attempt.response = webhook_response.content[+ : settings.EVENT_DELIVERY_ATTEMPT_RESPONSE_SIZE_LIMIT+ ]+ if attempt.response != webhook_response.content:+ attempt.response += "..."+ else:+ attempt.response = webhook_response.contentattempt.response_headers = json.dumps(webhook_response.response_headers)attempt.response_status_code = webhook_response.response_status_codeattempt.request_headers = json.dumps(webhook_response.request_headers)