From 6dca06e687d220609270ba427c1b0ff79dd431ba Mon Sep 17 00:00:00 2001 From: Eli Reisman Date: Tue, 27 Oct 2026 17:57:03 -0700 Subject: [PATCH 1/2] test: an event JSON cannot serialize is dropped alone Co-Authored-By: Claude Opus 5.5 --- posthog/test/test_before_send.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/posthog/test/test_before_send.py b/posthog/test/test_before_send.py index e2cda0a76..425294e62 100644 --- a/posthog/test/test_before_send.py +++ b/posthog/test/test_before_send.py @@ -16,6 +16,10 @@ ) +_CIRCULAR: dict = {} +_CIRCULAR["self"] = _CIRCULAR + + class TestClient(unittest.TestCase): @classmethod def setUpClass(cls): @@ -259,6 +263,8 @@ def test_before_send_callback_non_dict_output_drops_event(self): "private-value", ["malformed", "valid"], ), + # A value json cannot write costs only that event. + ("circular_reference", "private-key", _CIRCULAR, ["valid"]), ] ) def test_malformed_before_send_event_does_not_stop_consumer_or_shutdown( From fb96aafcfc299094a3e7dbddbb9087d09e2ac4ab Mon Sep 17 00:00:00 2001 From: Eli Reisman Date: Wed, 28 Oct 2026 12:55:16 -0700 Subject: [PATCH 2/2] test: cover an event that fails json after it is queued Co-Authored-By: Claude Opus 5.5 --- posthog/test/test_before_send.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/posthog/test/test_before_send.py b/posthog/test/test_before_send.py index 425294e62..78e2e0d77 100644 --- a/posthog/test/test_before_send.py +++ b/posthog/test/test_before_send.py @@ -263,8 +263,10 @@ def test_before_send_callback_non_dict_output_drops_event(self): "private-value", ["malformed", "valid"], ), - # A value json cannot write costs only that event. + # A circular value fails cleaning, so its event is dropped before it is queued. ("circular_reference", "private-key", _CIRCULAR, ["valid"]), + # A value that survives cleaning but not json costs only its queued event. + ("unserializable_value", "private-key", complex(1, 2), ["valid"]), ] ) def test_malformed_before_send_event_does_not_stop_consumer_or_shutdown(