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): treat Supavisor missing tenant identifier as non-retryable (#64362)

Tom Owersf4508b171297
diff --git a/posthog/temporal/data_imports/sources/postgres/source.py b/posthog/temporal/data_imports/sources/postgres/source.py
index 6053914560b3..9dd0b4c7bab1 100644
--- a/posthog/temporal/data_imports/sources/postgres/source.py
+++ b/posthog/temporal/data_imports/sources/postgres/source.py
@@ -231,6 +231,20 @@ class PostgresSource(SQLSource[PostgresSourceConfig], SSHTunnelMixin, ValidateDa
"deleted, or the pooler username/host is wrong. Check that your database is active "
"and the connection details are correct, then re-enable the sync."
),
+ # Supabase/Supavisor poolers reject a connection that carries no tenant identifier with
+ # "FATAL: (ENOIDENTIFIER) no tenant identifier provided (external_id or sni_hostname
+ # required)". The shared regional pooler host (e.g. aws-0-<region>.pooler.supabase.com)
+ # can't identify the project from SNI, so the pooler username must embed the project ref
+ # (e.g. "postgres.<project-ref>"). A plain username like "postgres" leaves the pooler with
+ # nothing to route on — deterministic until the customer fixes the username, so retrying
+ # just re-hits it. Match the stable message and exclude the volatile host/IP/port.
+ "no tenant identifier provided": (
+ "Your Supabase connection pooler rejected the connection because it 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 user for this source to the pooler username '
+ "shown in your Supabase dashboard, then re-enable the sync."
+ ),
"error received from server in SCRAM exchange: Wrong password": None,
# The server (commonly Supabase's Supavisor transaction pooler on port 6543) rejects the
# SASL/SCRAM credential exchange with "FATAL: SASL authentication failed" instead of
diff --git a/posthog/temporal/data_imports/sources/postgres/test_postgres.py b/posthog/temporal/data_imports/sources/postgres/test_postgres.py
index f65a7024a1a7..79619da14740 100644
--- a/posthog/temporal/data_imports/sources/postgres/test_postgres.py
+++ b/posthog/temporal/data_imports/sources/postgres/test_postgres.py
@@ -468,6 +468,37 @@ class TestPostgresSourceNonRetryableErrors:
is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())
assert is_non_retryable, f"Missing pooler tenant/user error should be non-retryable: {error_msg}"
+ @pytest.mark.parametrize(
+ "error_msg",
+ [
+ # Supabase Supavisor rejects a connection with no tenant identifier when the pooler
+ # username omits the project ref. The host/IP and port are volatile; the message is stable.
+ 'connection failed: connection to server at "54.255.219.82", port 5432 failed: FATAL: (ENOIDENTIFIER) no tenant identifier provided (external_id or sni_hostname required)',
+ # The real production message repeats the line (newlines are normalized to spaces upstream).
+ 'connection failed: connection to server at "52.74.252.201", port 5432 failed: FATAL: (ENOIDENTIFIER) no tenant identifier provided (external_id or sni_hostname required) connection to server at "52.74.252.201", port 5432 failed: FATAL: (ENOIDENTIFIER) no tenant identifier provided (external_id or sni_hostname required)',
+ ],
+ )
+ def test_missing_pooler_tenant_identifier_is_non_retryable(self, source, error_msg):
+ non_retryable = source.get_non_retryable_errors()
+ is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())
+ assert is_non_retryable, f"Missing pooler tenant identifier error should be non-retryable: {error_msg}"
+
+ @pytest.mark.parametrize(
+ "error_msg",
+ [
+ # Supabase Supavisor rejects a connection with no tenant identifier when the pooler
+ # username omits the project ref. The host/IP and port are volatile; the message is stable.
+ 'connection failed: connection to server at "54.255.219.82", port 5432 failed: FATAL: (ENOIDENTIFIER) no tenant identifier provided (external_id or sni_hostname required)',
+ # The real production message repeats the line (newlines are normalized to spaces upstream).
+ 'connection failed: connection to server at "52.74.252.201", port 5432 failed: FATAL: (ENOIDENTIFIER) no tenant identifier provided (external_id or sni_hostname required) connection to server at "52.74.252.201", port 5432 failed: FATAL: (ENOIDENTIFIER) no tenant identifier provided (external_id or sni_hostname required)',
+ ],
+ )
+ def test_missing_pooler_tenant_identifier_returns_friendly_message(self, source, error_msg):
+ non_retryable = source.get_non_retryable_errors()
+ friendly = [reason for pattern, reason in non_retryable.items() if pattern in error_msg and reason]
+ assert friendly, "Missing pooler tenant identifier error should surface an actionable message"
+ assert "project ref" in friendly[0]
+
@pytest.mark.parametrize(
"error_msg",
[