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): surface a retry prompt for transient validation errors (#66944)

Tom Owersd0b4113bd23b
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 d9a39ec214c8..742ae2fe8f67 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
@@ -296,8 +296,9 @@ class GoogleAdsSource(
team_id: int,
schema_name: Optional[str] = None,
) -> tuple[bool, str | None]:
- from products.warehouse_sources.backend.temporal.data_imports.sources.google_ads.google_ads import (
- google_ads_client, # noqa: PLC0415
+ from products.warehouse_sources.backend.temporal.data_imports.sources.google_ads.google_ads import ( # noqa: PLC0415
+ _is_transient_grpc_error,
+ google_ads_client,
)
try:
@@ -340,4 +341,13 @@ class GoogleAdsSource(
"Your Google Ads connection is no longer available — it may have been disconnected. "
"Please reconnect your Google Ads account.",
)
+ # A transient Google-side blip (INTERNAL / UNAVAILABLE) stringifies as a raw gRPC status and
+ # protobuf failure dump the user can't act on. The sync rides these out in-process; here on
+ # the interactive create path we surface a clean retry prompt instead of leaking the dump.
+ if _is_transient_grpc_error(e):
+ return (
+ False,
+ "Google Ads returned a temporary error while validating your credentials. This is "
+ "usually a transient issue on Google's side — please try again in a moment.",
+ )
return False, f"Error validating credentials: {error_message}"
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 923b3d88d98f..94e63c8bf7c0 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
@@ -363,6 +363,24 @@ class TestValidateCredentials:
assert ok is False
assert "reconnect your Google Ads account" in (message or "")
+ def test_transient_google_side_error_returns_retry_message(self):
+ # A transient INTERNAL/UNAVAILABLE blip from Google stringifies as a raw gRPC status plus a
+ # protobuf failure dump. Surface a clean retry prompt instead of leaking that to the wizard.
+ config = GoogleAdsSourceConfig(customer_id="1234567890", google_ads_integration_id=1)
+ client = mock.Mock()
+ client.get_service.return_value.list_accessible_customers.side_effect = (
+ google_api_exceptions.InternalServerError("500 Internal error encountered.")
+ )
+ with mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.google_ads.google_ads.google_ads_client",
+ return_value=client,
+ ):
+ ok, message = GoogleAdsSource().validate_credentials(config, team_id=1)
+
+ assert ok is False
+ assert "try again" in (message or "")
+ assert "Internal error encountered" not in (message or "")
+
def _google_ads_exception(request_error: int) -> GoogleAdsException:
failure = GoogleAdsFailure(