: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(supabase): map pooler auth and tenant errors during validation (#69899)
Tom Owers52dd0adaf149
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 76b3b36302cc..94f25febf396 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@@ -85,6 +85,29 @@ PostgresErrors = {"database project is paused or deleted, or the pooler username/host is wrong. Check that ""your database is active and the connection details are correct."),+ # Supabase/Supavisor's shared regional pooler (aws-0-<region>.pooler.supabase.com) can't+ # identify the project from SNI, so the pooler username must embed the project ref (for example+ # "postgres.<project-ref>"). A plain "postgres" username leaves it nothing to route on and it+ # rejects the connection with "FATAL: (ENOIDENTIFIER) no tenant identifier provided".+ # `get_non_retryable_errors` already handles this on the streaming path; map it here too so+ # validation returns an actionable message instead of the generic fallback.+ "no tenant identifier provided": (+ 'Your connection pooler couldn\'t identify your project ("no tenant identifier provided"). '+ "On the shared pooler host the username must include your project ref (for example "+ '"postgres.<project-ref>"). Update the username to the pooler username shown in your '+ "Supabase dashboard and try again."+ ),+ # Some poolers (for example Supabase's transaction pooler on port 6543) reject bad credentials+ # during the SASL/SCRAM exchange with "FATAL: SASL authentication failed" instead of libpq's+ # "password authentication failed for user", so none of the password keys above substring-match+ # it. `get_non_retryable_errors` already handles this on the streaming path; map it here too so+ # validation returns an actionable message instead of the generic fallback.+ "SASL authentication failed": (+ 'Your database rejected the credentials during authentication ("SASL authentication '+ 'failed"). This usually means the username or password is wrong. Some connection poolers '+ "(for example Supabase's transaction pooler) also require a pooler-specific username such "+ "as postgres.<project-ref>. Check your credentials and try again."+ ),"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 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 38ccb890c655..32fe70bbbc94 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@@ -2714,6 +2714,27 @@ class TestValidateCredentialsErrorMapping:"database project is paused or deleted, or the pooler username/host is wrong. Check that ""your database is active and the connection details are correct.",),+ # Supabase's transaction pooler (port 6543) rejects bad credentials during the+ # SASL/SCRAM exchange rather than with libpq's "password authentication failed".+ (+ 'connection failed: connection to server at "10.0.0.1", port 6543 failed: '+ "FATAL: SASL authentication failed",+ 'Your database rejected the credentials during authentication ("SASL '+ 'authentication failed"). This usually means the username or password is wrong. '+ "Some connection poolers (for example Supabase's transaction pooler) also require a "+ "pooler-specific username such as postgres.<project-ref>. Check your credentials "+ "and try again.",+ ),+ # Supabase/Supavisor's shared pooler rejects a connection whose username carries no+ # project ref with "(ENOIDENTIFIER) no tenant identifier provided".+ (+ 'connection failed: connection to server at "10.0.0.1", port 5432 failed: '+ "FATAL: (ENOIDENTIFIER) no tenant identifier provided (external_id or sni_hostname required)",+ "Your connection pooler couldn't identify your project (\"no tenant identifier "+ 'provided"). On the shared pooler host the username must include your project ref '+ '(for example "postgres.<project-ref>"). Update the username to the pooler username '+ "shown in your Supabase dashboard and try again.",+ ),# Invalid SSL-negotiation response — the host/port isn't a Postgres server speaking SSL.('connection failed: connection to server at "66.33.22.254", port 41667 failed: '