From fdb006de2c8bf3304c684a1be77959f716714955 Mon Sep 17 00:00:00 2001 From: Ben White Date: Tue, 19 Mar 2024 16:17:50 +0100 Subject: [PATCH 1/2] Fix return data for 204 status --- posthog/api/authentication.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/posthog/api/authentication.py b/posthog/api/authentication.py index 9b7dc954a97fa..10538c1d77ceb 100644 --- a/posthog/api/authentication.py +++ b/posthog/api/authentication.py @@ -179,6 +179,10 @@ def create(self, request: Request, *args: Any, **kwargs: Any) -> Response: """ response = super().create(request, *args, **kwargs) response.status_code = getattr(self, "SUCCESS_STATUS_CODE", status.HTTP_200_OK) + + if response.status_code == status.HTTP_204_NO_CONTENT: + response.data = None + return response From a2530373975099765c6480677f03422fc63156b6 Mon Sep 17 00:00:00 2001 From: Ben White Date: Tue, 19 Mar 2024 16:20:18 +0100 Subject: [PATCH 2/2] Fix --- posthog/api/test/test_authentication.py | 1 + 1 file changed, 1 insertion(+) diff --git a/posthog/api/test/test_authentication.py b/posthog/api/test/test_authentication.py index a33a59dd0549b..ef83517c918c7 100644 --- a/posthog/api/test/test_authentication.py +++ b/posthog/api/test/test_authentication.py @@ -317,6 +317,7 @@ def test_anonymous_user_can_request_password_reset(self, mock_capture): response = self.client.post("/api/reset/", {"email": self.CONFIG_EMAIL}) self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) self.assertEqual(response.content.decode(), "") + self.assertEqual(response.headers["Content-Length"], "0") user: User = User.objects.get(email=self.CONFIG_EMAIL) self.assertEqual(