: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(postgres): map unresolvable-host DNS failures to a validation error (#65583)
Tom Owersa279f20f9704
diff --git a/posthog/temporal/data_imports/sources/postgres/source.py b/posthog/temporal/data_imports/sources/postgres/source.pyindex 358b7cb86c9a..bf6fd1ba66f9 100644--- a/posthog/temporal/data_imports/sources/postgres/source.py+++ b/posthog/temporal/data_imports/sources/postgres/source.py@@ -69,6 +69,15 @@ PostgresErrors = {"your database is active and the connection details are correct."),"could not translate host name": "Could not connect to the host",+ # libpq prefixes a DNS-resolution failure with "could not translate host name ..." (matched+ # above), but the same getaddrinfo failure also surfaces as the raw socket wording with no such+ # prefix — "[Errno -2] Name or service not known" (EAI_NONAME) or its EAI_NODATA sibling+ # "[Errno -5] No address associated with hostname" — e.g. through an SSH tunnel or psycopg's+ # Python-side resolution. `get_non_retryable_errors` already treats both as non-retryable; map+ # them here too so credential validation returns an actionable message instead of surfacing the+ # customer's unresolvable host as captured error noise.+ "Name or service not known": "Could not resolve the database host. Check that the host is spelled correctly and reachable from the public internet.",+ "No address associated with hostname": "Could not resolve the database host. Check that the host is spelled correctly and reachable from the public internet.","Is the server running on that host and accepting TCP/IP connections": "Could not connect to the host on the port given",'database "': "Database does not exist","timeout expired": "Connection timed out. Does your database have our IP addresses allowed?",diff --git a/posthog/temporal/data_imports/sources/postgres/test_postgres.py b/posthog/temporal/data_imports/sources/postgres/test_postgres.pyindex cef4ac188951..b4bd27ce66af 100644--- a/posthog/temporal/data_imports/sources/postgres/test_postgres.py+++ b/posthog/temporal/data_imports/sources/postgres/test_postgres.py@@ -1934,6 +1934,17 @@ class TestValidateCredentialsErrorMapping:"PostgreSQL server speaking SSL. Check that the host and port point at your PostgreSQL server ""(not an HTTP, proxy, or edge endpoint) and that the database is running.",),+ # DNS-resolution failure surfaced as the raw socket wording (no libpq "could not+ # translate host name" prefix) — e.g. through an SSH tunnel or psycopg's Python-side+ # resolution. Must map to the actionable host message instead of being captured.+ (+ "[Errno -2] Name or service not known",+ "Could not resolve the database host. Check that the host is spelled correctly and reachable from the public internet.",+ ),+ (+ "[Errno -5] No address associated with hostname",+ "Could not resolve the database host. Check that the host is spelled correctly and reachable from the public internet.",+ ),# Unmapped errors fall back to the generic message.("some brand new failure",