:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(mailjet): use Sort=ID for campaigndraft endpoint (#62128)
Tom Owers78a0a5b3dc93
diff --git a/posthog/temporal/data_imports/sources/mailjet/settings.py b/posthog/temporal/data_imports/sources/mailjet/settings.pyindex 14b269d59b46..4af8aa74b5d5 100644--- a/posthog/temporal/data_imports/sources/mailjet/settings.py+++ b/posthog/temporal/data_imports/sources/mailjet/settings.py@@ -60,7 +60,9 @@ MAILJET_ENDPOINTS: dict[str, MailjetEndpointConfig] = {name="campaigndraft",path="campaigndraft",partition_key="CreatedAt",- sort="CreatedAt",+ # Mailjet rejects Sort=CreatedAt on campaigndraft ("Cannot sort on field createdat"),+ # so fall back to the monotonic ID for deterministic offset pagination.+ sort="ID",),"message": MailjetEndpointConfig(name="message",diff --git a/posthog/temporal/data_imports/sources/mailjet/tests/test_mailjet.py b/posthog/temporal/data_imports/sources/mailjet/tests/test_mailjet.pyindex 25f5ebe9fc7c..a35001d9e468 100644--- a/posthog/temporal/data_imports/sources/mailjet/tests/test_mailjet.py+++ b/posthog/temporal/data_imports/sources/mailjet/tests/test_mailjet.py@@ -142,14 +142,19 @@ class TestOffsetPagination:assert pages == []assert mock_session.return_value.get.call_count == 1+ @parameterized.expand([(name,) for name in ENDPOINTS])@patch("posthog.temporal.data_imports.sources.mailjet.mailjet.make_tracked_session")- def test_sort_param_sent(self, mock_session: MagicMock) -> None:+ def test_sort_param_sent(self, endpoint: str, mock_session: MagicMock) -> None:mock_session.return_value.get.return_value = _mock_response(json_payload=_page(1))- list(get_rows("key", "secret", "contact", MagicMock(), _mock_manager()))+ list(get_rows("key", "secret", endpoint, MagicMock(), _mock_manager()))params = mock_session.return_value.get.call_args.kwargs["params"]- assert params["Sort"] == MAILJET_ENDPOINTS["contact"].sort+ assert params["Sort"] == MAILJET_ENDPOINTS[endpoint].sort++ def test_campaigndraft_does_not_sort_on_created_at(self) -> None:+ # Regression guard for the Sort fallback documented in settings.py.+ assert MAILJET_ENDPOINTS["campaigndraft"].sort == "ID"class TestResume: