: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(meta_ads): drop the business field from the ad_account sync (#77748)
Tom Owerse3c6fbb53de9
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/schemas.py b/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/schemas.pyindex 9037d23f0131..2fbc10b72589 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/schemas.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/schemas.py@@ -355,7 +355,10 @@ RESOURCE_SCHEMAS: dict[MetaAdsResource, dict[str, Any]] = {"created_time","business_country_code","business_name",- "business",+ # No `business`: reading it needs the `business_management` scope, which the Meta+ # OAuth consent doesn't request (`ads_read` only) — see `AD_ACCOUNT_FIELDS` in+ # meta_ads.py, which excludes it from the account-listing request for the same reason.+ # Meta 400s the whole request when it's asked for, failing this table's sync outright."funding_source_details","disable_reason","is_prepay_account",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/test_meta_ads.py b/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/test_meta_ads.pyindex 80f25784fe38..d89402b10617 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/test_meta_ads.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/test_meta_ads.py@@ -1758,3 +1758,12 @@ class TestSingleObjectEndpoint:with pytest.raises(Exception, match=META_AUTH_ERROR_MESSAGE):self._rows(monkeypatch, response)++ def test_field_list_omits_business_field_requiring_ungranted_scope(self) -> None:+ # `business` needs the `business_management` scope, which the Meta OAuth consent never+ # requests (`ads_read` only), so Meta 400s the whole request whenever it's asked for —+ # failing every sync of this table. `business_name` and `business_country_code` are plain+ # fields with no such requirement and must stay.+ field_names = get_meta_ads_schemas()[MetaAdsResource.AdAccount].field_names+ assert "business" not in field_names+ assert {"business_name", "business_country_code"} <= set(field_names)