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.

feat(google_ads): treat REQUESTED_METRICS_FOR_MANAGER as non-retryable (#56475)

Tom Owers35557b856b07
diff --git a/posthog/temporal/data_imports/sources/google_ads/source.py b/posthog/temporal/data_imports/sources/google_ads/source.py
index 66a97bfac749..f53bfd2c116f 100644
--- a/posthog/temporal/data_imports/sources/google_ads/source.py
+++ b/posthog/temporal/data_imports/sources/google_ads/source.py
@@ -50,6 +50,7 @@ class GoogleAdsSource(
"ACCESS_TOKEN_SCOPE_INSUFFICIENT": None,
"Account has been deleted": None,
"INVALID_CUSTOMER_ID": None,
+ "REQUESTED_METRICS_FOR_MANAGER": "Metrics cannot be requested for a Google Ads manager (MCC) account. Reconfigure this source with a client account customer ID, or enable the MCC option and provide both the manager and client customer IDs.",
# google.auth.exceptions.RefreshError raised when the stored OAuth refresh token
# has been revoked, expired, or is otherwise rejected by Google's token endpoint.
# Retrying cannot recover — the user must reconnect their Google Ads account.
diff --git a/posthog/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py b/posthog/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py
index c0790c874316..6f6acf1854b2 100644
--- a/posthog/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py
+++ b/posthog/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py
@@ -27,6 +27,12 @@ class TestGoogleAdsNonRetryableErrors:
@pytest.mark.parametrize(
"error_msg",
[
+ # Observed in production: requesting metrics against a manager (MCC) account.
+ (
+ "errors {\n error_code {\n query_error: REQUESTED_METRICS_FOR_MANAGER\n }\n "
+ 'message: "Metrics cannot be requested for a manager account. To retrieve metrics, '
+ 'issue separate requests against each client account under the manager account."\n}\n'
+ ),
# Other Google Ads specific failures that should stop retrying.
"PERMISSION_DENIED: The caller does not have permission",
"UNAUTHENTICATED: Request had invalid authentication credentials",
@@ -61,12 +67,18 @@ class TestGoogleAdsNonRetryableErrors:
"ACCESS_TOKEN_SCOPE_INSUFFICIENT",
"Account has been deleted",
"INVALID_CUSTOMER_ID",
+ "REQUESTED_METRICS_FOR_MANAGER",
"invalid_grant",
],
)
def test_documented_patterns_present(self, pattern):
assert pattern in self.non_retryable
+ def test_requested_metrics_for_manager_has_user_facing_message(self):
+ message = self.non_retryable["REQUESTED_METRICS_FOR_MANAGER"]
+ assert message is not None
+ assert "manager" in message.lower()
+
def test_invalid_grant_has_friendly_message(self):
friendly = self.non_retryable["invalid_grant"]
assert friendly is not None