Skip to content

: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.

fix(google_ads): handle non-dict is_mcc_account in config validation (#66858)

Tom Owers98838542106a
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/source.py
index 57a83420b445..d9a39ec214c8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/source.py
@@ -252,8 +252,11 @@ class GoogleAdsSource(
)
is_valid = False
- is_mcc_account = job_inputs.get("is_mcc_account", {})
- if is_mcc_account.get("enabled"):
+ # The switch-group field is a dict (`{"enabled": ..., "mcc_client_id": ...}`) when
+ # sent from the setup form, but API callers may send a plain bool, so only treat it
+ # as enabled when it's the expected dict shape.
+ is_mcc_account = job_inputs.get("is_mcc_account")
+ if isinstance(is_mcc_account, dict) and is_mcc_account.get("enabled"):
raw_mcc_client_id = is_mcc_account.get("mcc_client_id", "")
if raw_mcc_client_id and not re.fullmatch(r"\d{10}", clean_customer_id(raw_mcc_client_id) or ""):
errors.append(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py
index 08d3b777072b..2dc76504f14b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py
@@ -99,6 +99,13 @@ class TestGoogleAdsValidateConfig:
}
assert len(self._manager_id_errors(job_inputs)) == 1
+ @pytest.mark.parametrize("is_mcc_account", [False, True, None])
+ def test_non_dict_is_mcc_account_does_not_crash(self, is_mcc_account):
+ # API callers may send is_mcc_account as a plain bool instead of the switch-group dict;
+ # validate_config must not crash trying to read `.get("enabled")` off it.
+ job_inputs = {"customer_id": "1234567890", "is_mcc_account": is_mcc_account}
+ assert self._manager_id_errors(job_inputs) == []
+
class TestGoogleAdsNonRetryableErrors:
def setup_method(self):