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-search-console): name a next step when the picker lists no property (#107493)

Tom Owers900443833c4e
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_search_console/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_search_console/source.py
index 0814034a3013..d0b55adf3a34 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_search_console/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_search_console/source.py
@@ -157,6 +157,12 @@ class GoogleSearchConsoleSource(
raise IntegrationAccountListingError(
"Could not authenticate with Google Search Console. Please reconnect the integration."
)
+ if not sites:
+ # Google answers 200 with an empty list both when the account owns no property and
+ # when the Search Console scope was not granted. Returning [] leaves the picker on a
+ # generic empty state that names no next step, so raise the same message the 403
+ # listing path uses.
+ raise IntegrationAccountListingError(_PROPERTY_LIST_ACCESS_ERROR)
# GSC has no name distinct from the site url, so value and display_name are the same.
return [
IntegrationAccount(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_search_console/tests/test_google_search_console_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_search_console/tests/test_google_search_console_source.py
index cf53f5b56def..4313c53dcdb2 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_search_console/tests/test_google_search_console_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_search_console/tests/test_google_search_console_source.py
@@ -273,6 +273,26 @@ def test_get_oauth_accounts_reports_why_the_property_list_failed(body, expected_
assert expected_substring in str(raised.value)
+def test_get_oauth_accounts_names_a_next_step_when_the_account_owns_no_property():
+ from products.warehouse_sources.backend.temporal.data_imports.sources.common.integration_accounts import (
+ IntegrationAccountListingError,
+ )
+
+ with (
+ mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.google_search_console.source.google_search_console_session"
+ ),
+ mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.google_search_console.source.list_sites",
+ return_value=[],
+ ),
+ pytest.raises(IntegrationAccountListingError) as raised,
+ ):
+ GoogleSearchConsoleSource().get_oauth_accounts(integration_id=1, team_id=1)
+
+ assert "can't read any Search Console property" in str(raised.value)
+
+
def test_validate_credentials_missing_integration_returns_reconnect_message():
from posthog.models.integration import Integration