: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(klaviyo): cap Get Lists page size at Klaviyo's documented max (#65387)
Tom Owers66ee5e36eadf
diff --git a/posthog/temporal/data_imports/sources/klaviyo/test_klaviyo.py b/posthog/temporal/data_imports/sources/klaviyo/test_klaviyo.pyindex 3705fcbbc4fe..888d2f11525f 100644--- a/posthog/temporal/data_imports/sources/klaviyo/test_klaviyo.py+++ b/posthog/temporal/data_imports/sources/klaviyo/test_klaviyo.py@@ -246,6 +246,19 @@ class TestListProfilesFanOut:assert list_profiles.supports_append is Falseassert list_profiles.should_sync_default is False+ def test_lists_request_stays_within_klaviyo_page_size_cap(self, monkeypatch: Any) -> None:+ # Klaviyo's Get Lists endpoint caps page[size] at 10; a larger value 400s the whole fan-out.+ fetched_urls: list[str] = []++ def fake_fetch(session: Any, url: str, headers: dict[str, str], logger: Any) -> dict:+ fetched_urls.append(url)+ return {"data": [], "links": {"next": None}}++ monkeypatch.setattr(klaviyo, "_fetch_page", fake_fetch)+ list(klaviyo._iter_list_ids(MagicMock(), {}, MagicMock()))++ assert fetched_urls == ["https://a.klaviyo.com/api/lists?page[size]=10"]+def test_fans_out_over_every_list_into_membership_rows(self, monkeypatch: Any) -> None:pages = {"https://a.klaviyo.com/api/lists?page[size]=10": {