From 7bce41d11e7039e9f2f21bb42240cb3616697ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hansmann?= Date: Wed, 10 Apr 2024 17:07:53 +0200 Subject: [PATCH] PB-409: fix broken health check and collections endpoint Since this morning, the collections and health check endpoint are returning 500. This is most likely caused by a special character in a newly updated collection description or ID field. The error is, decode cannot decode a byte 0xc3 in position 199: unexpected end of data. To prevent this, we now first decode the whole response.content and strip it afterwards, rather than the other way round. --- app/middleware/logging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/middleware/logging.py b/app/middleware/logging.py index 10095f24..5fa71038 100644 --- a/app/middleware/logging.py +++ b/app/middleware/logging.py @@ -54,7 +54,7 @@ def __call__(self, request): # HttpResponse and JSONResponse sure have # (e.g. WhiteNoiseFileResponse doesn't) if isinstance(response, (HttpResponse, JsonResponse)): - extra["response"]["payload"] = response.content[:200].decode() + extra["response"]["payload"] = response.content.decode()[:200] logger.info("Response %s", response.status_code, extra=extra) # Code to be executed for each request/response after