: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(awin): handle a null list key on a paginated page (#129857)
Tom Owersf4860acc028b
diff --git a/products/warehouse_sources/sources/awin/awin.py b/products/warehouse_sources/sources/awin/awin.pyindex 4a154266212c..071c21dab2e7 100644--- a/products/warehouse_sources/sources/awin/awin.py+++ b/products/warehouse_sources/sources/awin/awin.py@@ -252,7 +252,8 @@ def _rows_from_response(if config.single_row:rows = [data] if isinstance(data, dict) else []elif config.data_key is not None:- rows = data.get(config.data_key, []) if isinstance(data, dict) else []+ # Awin can send the list key as null on an empty page, not only as an empty list.+ rows = (data.get(config.data_key) or []) if isinstance(data, dict) else []else:rows = data if isinstance(data, list) else []diff --git a/products/warehouse_sources/sources/awin/tests/test_awin.py b/products/warehouse_sources/sources/awin/tests/test_awin.pyindex 96f74ce606ff..d5e9bd4a25a7 100644--- a/products/warehouse_sources/sources/awin/tests/test_awin.py+++ b/products/warehouse_sources/sources/awin/tests/test_awin.py@@ -166,6 +166,22 @@ class TestRowsFromResponse:rows = _rows_from_response(AWIN_ENDPOINTS["advertiser_publishers"], data, AwinFanoutTarget(advertiser_id=90))assert rows == [{"id": 7, "name": "Some publisher", "advertiserId": 90}]+ @parameterized.expand(+ [+ (+ "transaction_queries_null_page_items",+ "transaction_queries",+ {"pageItems": None, "totalPagesAvailable": 0},+ ),+ ("transaction_queries_missing_page_items", "transaction_queries", {"totalPagesAvailable": 0}),+ ("offers_null_data", "offers", {"data": None, "pagination": {"page": 1, "pageSize": 200, "total": 0}}),+ ("commission_groups_null_groups", "commission_groups", {"advertiser": 9, "commissionGroups": None}),+ ]+ )+ def test_null_or_missing_list_key_yields_no_rows(self, _name: str, endpoint: str, data: dict[str, Any]) -> None:+ rows = _rows_from_response(AWIN_ENDPOINTS[endpoint], data, AwinFanoutTarget(publisher_id=42, advertiser_id=9))+ assert rows == []+class TestDiscoverAccountIds:@parameterized.expand([("publisher", [1, 3]), ("advertiser", [2])])