: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(data-warehouse): explain a short internal host name that won't resolve (#111458)
Tom Owers73421a02a553
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/common/mixins.py b/products/warehouse_sources/backend/temporal/data_imports/sources/common/mixins.pyindex afc94a657964..561eebd563e9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/common/mixins.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/common/mixins.py@@ -39,6 +39,13 @@ _INTERNAL_IP_ERROR = ("Use a host that's reachable from the public internet.")_DNS_FAILURE_ERROR = "Host could not be resolved"+# A name with no dot, such as a Docker Compose service name, only resolves inside the network that+# defines it, so "check the spelling" sends the customer the wrong way. Sources match the "Couldn't+# resolve the host" prefix to stop retrying a broken sync, so keep it.+_SHORT_HOST_NAME_ERROR = (+ "Couldn't resolve the host because it's a short name that only works inside your own network. "+ "Enter the full public hostname or IP address instead."+)_MALFORMED_HOST_ERROR = ("Enter a single hostname or IP address for the host, without a port, path, comma, space or trailing dot.")@@ -365,6 +372,9 @@ def _host_check_exemption(host: str, team_id: int | None) -> str | None:def _check_resolved_ips(host: str, team_id: int | None, resolved_ips: list[str]) -> HostResolution:if not resolved_ips:_log_host_check(host, team_id, "block", "dns_failure", _DNS_FAILURE_ERROR)+ normalized = _normalize_host(host)+ if "." not in normalized and ":" not in normalized:+ return HostResolution(connect_host=None, error=_SHORT_HOST_NAME_ERROR)return HostResolution(connect_host=None,error=(diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/common/test_mixins.py b/products/warehouse_sources/backend/temporal/data_imports/sources/common/test_mixins.pyindex b303f258bbc6..af7b410c6eda 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/common/test_mixins.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/common/test_mixins.py@@ -241,6 +241,20 @@ class TestIsHostSafe(SimpleTestCase):assert "nonexistent.invalid" in errorassert "resolve" in error+ @parameterized.expand([("service_name", "postgres"), ("hyphenated", "my-db")])+ @override_settings(CLOUD_DEPLOYMENT="US")+ def test_unresolvable_short_host_name_explains_it_is_internal(self, _name: str, host: str):+ with patch(+ f"{_MIXINS_MODULE}.socket.getaddrinfo",+ side_effect=socket.gaierror(socket.EAI_NONAME, "Name or service not known"),+ ):+ valid, error = _is_host_safe(host, team_id=999)+ assert not valid+ assert error is not None+ assert error.startswith("Couldn't resolve the host")+ assert "short name" in error+ assert host not in error+@override_settings(CLOUD_DEPLOYMENT="US")def test_malformed_host_label_blocked(self):valid, error = _is_host_safe("a" * 92, team_id=999)