: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): explain rejected database users during source setup (#111553)
Tom Owersc5a6ef7f1267
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.pyindex 4f898afd3c17..c75171739cd2 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@@ -226,6 +226,20 @@ PostgresErrors = {'authentication failures ("too many authentication failures"). This usually means the '"username or password is wrong. Check your credentials and try again."),+ # A server using `pam` auth in pg_hba.conf words a bad password this way, so the libpq+ # password keys above don't match it.+ "PAM authentication failed": _INVALID_CREDENTIALS_VALIDATION_ERROR,+ # A PgBouncer-style pooler (for example Supabase's on port 6543) rejects a username that isn't+ # in its own user list before Postgres sees it.+ "no such user": (+ "Your connection pooler doesn't recognize this username. Use the username your pooler "+ "expects, such as postgres.<project-ref> for Supabase, then try again."+ ),+ # The role exists but has NOLOGIN, which is the default for a role made with CREATE ROLE.+ "is not permitted to log in": (+ "Your database user isn't allowed to sign in. Grant it the LOGIN privilege or use a "+ "different user, then try again."+ ),"could not translate host name": _DNS_RESOLUTION_VALIDATION_ERROR,# 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 suchdiff --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.pyindex 42845bf07d3c..bcc23d6e5188 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@@ -5078,6 +5078,22 @@ 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 "10.0.0.1", port 5432 failed: '+ 'FATAL: PAM authentication failed for user "example_user"',+ "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 6543 failed: FATAL: no such user',+ "Your connection pooler doesn't recognize this username. Use the username your pooler "+ "expects, such as postgres.<project-ref> for Supabase, then try again.",+ ),+ (+ 'connection failed: connection to server at "10.0.0.1", port 5432 failed: '+ 'FATAL: role "example_user" is not permitted to log in',+ "Your database user isn't allowed to sign in. Grant it the LOGIN privilege or use a "+ "different user, then try again.",+ ),(f"{HOST_RESOLUTION_TIMEOUT_ERROR} after 15.0s","PostHog couldn't resolve your database host right now. Check the host name, then try "