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(warehouse-sources): make Postgres credential errors actionable (#83423)

Tom Owers76943f207d40
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/source.py
index 1f30f7262715..e819cb0473c7 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/source.py
@@ -101,10 +101,16 @@ _DNS_RESOLUTION_ERROR = (
"and reachable from the public internet, then re-enable the sync."
)
+# Same failure at credential-validation time (no sync exists yet), so point at re-entering details
+# rather than re-enabling a sync.
+_INVALID_CREDENTIALS_VALIDATION_ERROR = (
+ "The database rejected the username or password. Check the user and password for this source and try again."
+)
+
PostgresErrors = {
- "password authentication failed for user": "Invalid user or password",
+ "password authentication failed for user": _INVALID_CREDENTIALS_VALIDATION_ERROR,
# libpq reports a bad password via SCRAM with a different wording than the line above.
- "error received from server in SCRAM exchange: Wrong password": "Invalid user or password",
+ "error received from server in SCRAM exchange: Wrong password": _INVALID_CREDENTIALS_VALIDATION_ERROR,
# Supabase/Supavisor poolers report a missing tenant/user during credential validation with
# "FATAL: (ENOTFOUND) tenant/user <user> not found" — the project is paused/deleted or the
# pooler username/host is wrong. `get_non_retryable_errors` already handles this on the
@@ -156,7 +162,7 @@ PostgresErrors = {
"Network is unreachable": _HOST_UNREACHABLE_ERROR,
"No route to host": _HOST_UNREACHABLE_ERROR,
"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",
+ 'database "': "The database named in your connection details doesn't exist on this server. Check the database name is correct and try again.",
"timeout expired": "Connection timed out. Check that your database is reachable from the public internet and that PostHog's egress IP addresses are allowed through your firewall (see the docs). For a database that can't be exposed publicly, use the SSH tunnel option.",
"the database system is starting up": "Your database is starting up or recovering. Wait a moment and try again.",
"SSL/TLS connection is required": "SSL/TLS connection is required but your database does not support it. Please enable SSL/TLS on your PostgreSQL server.",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.py
index 509ca681d763..d103f6fed899 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.py
@@ -3587,7 +3587,7 @@ class TestValidateCredentialsErrorMapping:
(
'connection failed: connection to server at "1.2.3.4", port 5432 failed: '
"error received from server in SCRAM exchange: Wrong password",
- "Invalid user or password",
+ "The database rejected the username or password. Check the user and password for this source and try again.",
),
(
'connection failed: connection to server at "1.2.3.4", port 5432 failed: '