: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(warehouse_sources): stop retrying metabase syncs on unresolvable host (#73381)
Tom Owers77741ee21b75
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/metabase/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/metabase/source.pyindex 1b07be5d0aa0..c4d66938aef5 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/metabase/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/metabase/source.py@@ -133,6 +133,11 @@ The API key (or user) needs read access to the data you want to sync.""","403 Client Error": "Your Metabase credentials lack the permissions needed to sync this data. Grant read access and reconnect.",HOST_NOT_ALLOWED_ERROR: "The Metabase host is not allowed. Please use your instance's public URL.",SESSION_RESPONSE_NOT_JSON_ERROR: "Metabase didn't return a valid session response. Check that the Instance URL points to your Metabase instance, then reconnect.",+ # `_is_host_safe` raises this when the Instance URL doesn't resolve via DNS — a+ # hostname the customer typed wrong or one that's no longer publicly reachable.+ # Deterministic and permanent until the Instance URL is corrected, so stop+ # retrying. Match the stable prefix, not the customer's hostname that follows it.+ "Couldn't resolve the host": "The Metabase Instance URL could not be resolved via DNS. Check that it's spelled correctly and reachable from the public internet, then reconnect.",}def _build_auth(self, config: MetabaseSourceConfig) -> MetabaseAuth:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/metabase/tests/test_metabase_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/metabase/tests/test_metabase_source.pyindex 88923ca1c9d2..01a9ab70cab9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/metabase/tests/test_metabase_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/metabase/tests/test_metabase_source.py@@ -1,3 +1,4 @@+import socketfrom typing import Literalimport pytest@@ -5,6 +6,7 @@ from unittest import mockfrom posthog.schema import ReleaseStatus, SourceFieldInputConfig, SourceFieldSelectConfig+from products.warehouse_sources.backend.temporal.data_imports.sources.common.mixins import _is_host_safefrom products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.metabase import (MetabaseAuthMethodConfig,MetabaseSourceConfig,@@ -67,11 +69,43 @@ class TestMetabaseSource:@pytest.mark.parametrize("expected_key",- ["401 Client Error", "403 Client Error", "Invalid Metabase credentials", SESSION_RESPONSE_NOT_JSON_ERROR],+ [+ "401 Client Error",+ "403 Client Error",+ "Invalid Metabase credentials",+ SESSION_RESPONSE_NOT_JSON_ERROR,+ "Couldn't resolve the host",+ ],)def test_non_retryable_errors(self, expected_key):assert expected_key in self.source.get_non_retryable_errors()+ def test_dns_resolution_failure_message_is_classified_non_retryable(self):+ # `_is_host_safe` raises this exact message when the Instance URL doesn't resolve via+ # DNS — a permanent, deterministic failure until it's corrected. Build the message via+ # the real `_is_host_safe` code path (not a hand-typed copy) so this test breaks if+ # either side's wording drifts from the classifier's key.+ with (+ mock.patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.common.mixins.is_cloud",+ return_value=True,+ ),+ mock.patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.common.mixins.get_instance_region",+ return_value="US",+ ),+ mock.patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.common.mixins.socket.getaddrinfo",+ side_effect=socket.gaierror,+ ),+ ):+ ok, err = _is_host_safe("nonexistent.example", team_id=999)++ assert not ok+ assert err is not None+ non_retryable = self.source.get_non_retryable_errors()+ assert any(key in err for key in non_retryable)+def test_get_schemas_returns_all_endpoints(self):schemas = self.source.get_schemas(self.config, self.team_id)assert {s.name for s in schemas} == set(ENDPOINTS)