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(postgres): recognize a rejected password without the user name (#123840)

Tom Owers955b8e7ef05b
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 b42ec63db6cc..3670be0733cd 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
@@ -205,7 +205,8 @@ POSTGRES_HOST_CHECK_SOURCE_TYPE = "postgres"
PostgresErrors = {
**CERTIFICATE_ERRORS,
- "password authentication failed for user": _INVALID_CREDENTIALS_VALIDATION_ERROR,
+ # Some servers end the message here, without libpq's "for user <name>".
+ "password authentication failed": _INVALID_CREDENTIALS_VALIDATION_ERROR,
# A proxy/pooler in front of some providers rejects bad credentials during its own
# database-identification step instead of libpq's "password authentication failed for user",
# wrapping the rejection in its own sentence ("Failed to identify your database: Your Postgres
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 bea8d9f063d5..663af5ddb6b0 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
@@ -5666,6 +5666,11 @@ class TestValidateCredentialsErrorMapping:
"Please check your username and password and try again.",
"The database rejected the username or password. Check the user and password for this source and try again.",
),
+ (
+ 'connection failed: connection to server at "203.0.113.20", port 5432 failed: '
+ "FATAL: password authentication failed",
+ "The database rejected the username or password. Check the user and password for this source and try again.",
+ ),
(
'connection failed: connection to server at "10.0.0.1", port 5432 failed: '
'FATAL: PAM authentication failed for user "example_user"',