: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(data-warehouse): cap gainsight px feature and segment page size (#103677)
Tom Owersd9ee989c8b41
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/settings.pyindex bda54157183e..4a55d405e3d4 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/settings.py@@ -12,10 +12,12 @@ GAINSIGHT_PX_HOSTS: dict[str, str] = {"us2": "https://api-us2.aptrinsic.com/v1",}-# Scroll endpoints (users/accounts) cap `pageSize` at 1000; the page-number endpoints cap it lower-# (articles/kcbot allow up to 500). We keep the request size healthy but under each documented cap.+# The `pageSize` cap differs per endpoint and a request above an endpoint's cap is rejected with a+# 400, so every endpoint carries its own size. Scroll endpoints (users/accounts) allow up to 1000,+# engagement/articles/kcbot allow up to 500, and feature/segment allow only 200.SCROLL_PAGE_SIZE = 1000PAGE_NUMBER_PAGE_SIZE = 500+FEATURE_SEGMENT_PAGE_SIZE = 200PaginationMode = Literal["scroll", "page"]@@ -78,14 +80,14 @@ GAINSIGHT_PX_ENDPOINTS: dict[str, GainsightPxEndpointConfig] = {path="/feature",data_key="features",pagination="page",- page_size=PAGE_NUMBER_PAGE_SIZE,+ page_size=FEATURE_SEGMENT_PAGE_SIZE,),"segments": GainsightPxEndpointConfig(name="segments",path="/segment",data_key="segments",pagination="page",- page_size=PAGE_NUMBER_PAGE_SIZE,+ page_size=FEATURE_SEGMENT_PAGE_SIZE,),"engagements": GainsightPxEndpointConfig(name="engagements",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/tests/test_gainsight_px.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/tests/test_gainsight_px.pyindex e2a18f172752..efae0d6d76ed 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/tests/test_gainsight_px.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/tests/test_gainsight_px.py@@ -226,6 +226,32 @@ class TestPageNumberPagination:assert params[0]["pageNumber"] == 4+# Maxima published in the vendor's OpenAPI spec (https://px-apidocs.gainsight.com/source.json). A+# pageSize above an endpoint's maximum is rejected with a 400 and fails the whole table.+VENDOR_PAGE_SIZE_MAXIMA: dict[str, int] = {+ "accounts": 1000,+ "articles": 500,+ "engagements": 500,+ "features": 200,+ "kc_bots": 500,+ "segments": 200,+ "users": 1000,+}+++class TestPageSizeCaps:+ @parameterized.expand(sorted(VENDOR_PAGE_SIZE_MAXIMA.items()))+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_requested_page_size_is_within_vendor_cap(self, endpoint: str, maximum: int, MockSession) -> None:+ session = MockSession.return_value+ data_key = GAINSIGHT_PX_ENDPOINTS[endpoint].data_key+ params = _wire(session, [_response(data_key, [{"id": "1"}], isLastPage=True, scrollId=None)])++ _rows(_source(endpoint, _make_manager()))++ assert params[0]["pageSize"] <= maximum++class TestRowNormalization:@mock.patch(CLIENT_SESSION_PATCH)def test_epoch_millis_fields_are_converted_during_iteration(self, MockSession, monkeypatch) -> None: