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 RDS Proxy wrong-password as non-retryable (#64084)

Tom Owersbd37278b672b
diff --git a/posthog/temporal/data_imports/sources/postgres/source.py b/posthog/temporal/data_imports/sources/postgres/source.py
index df3695532bbe..5661b6b030aa 100644
--- a/posthog/temporal/data_imports/sources/postgres/source.py
+++ b/posthog/temporal/data_imports/sources/postgres/source.py
@@ -198,6 +198,18 @@ class PostgresSource(SQLSource[PostgresSourceConfig], SSHTunnelMixin, ValidateDa
"could not translate host name": None,
"timeout expired connection to server at": None,
"password authentication failed for user": None,
+ # AWS RDS Proxy reports bad credentials with its own wording instead of PostgreSQL's
+ # "password authentication failed for user" — it validates against Secrets Manager and
+ # returns "The password that was provided for the role <role> is wrong." None of the
+ # password keys above substring-match this, so without its own key Temporal keeps
+ # retrying a credential mismatch that can only be fixed on the customer's side. Match the
+ # stable prefix and exclude the volatile role name.
+ "The password that was provided for the role": (
+ "Your database proxy (for example AWS RDS Proxy) rejected the credentials "
+ '("the password that was provided for the role is wrong"). Check that the username '
+ "and password configured for this source match what the proxy expects, then "
+ "re-enable the sync."
+ ),
"No primary key defined for table": None,
"failed: timeout expired": None,
# NOTE: "SSL connection has been closed unexpectedly" is intentionally NOT listed here.
diff --git a/posthog/temporal/data_imports/sources/postgres/test_postgres.py b/posthog/temporal/data_imports/sources/postgres/test_postgres.py
index e0486461d1a7..f0e5a80b1e22 100644
--- a/posthog/temporal/data_imports/sources/postgres/test_postgres.py
+++ b/posthog/temporal/data_imports/sources/postgres/test_postgres.py
@@ -272,6 +272,10 @@ class TestPostgresSourceNonRetryableErrors:
'connection failed: connection to server at "52.45.94.125", port 6543 failed: FATAL: (ENOTFOUND) tenant/user postgres.hksbxxtlcfeyyalgveif not found',
"ProtocolViolation: server login has been failing, cached error: connect timeout (server_login_retry)",
"server login has been failing, cached error: connection refused (server_login_retry)",
+ # AWS RDS Proxy rejects bad credentials with its own wording (validated against Secrets
+ # Manager), not PostgreSQL's "password authentication failed for user". Newlines are
+ # normalized to spaces upstream, so the real message arrives as the doubled single line.
+ 'connection failed: connection to server at "127.0.0.1", port 35425 failed: FATAL: The password that was provided for the role postgres is wrong. connection to server at "127.0.0.1", port 35425 failed: FATAL: This RDS Proxy requires TLS connections',
],
)
def test_permanent_connection_errors_are_non_retryable(self, source, error_msg):
@@ -326,6 +330,22 @@ class TestPostgresSourceNonRetryableErrors:
assert friendly, "Exceeded compute-time quota error should surface an actionable message"
assert "compute-time quota" in friendly[0]
+ @pytest.mark.parametrize(
+ "error_msg",
+ [
+ 'connection failed: connection to server at "127.0.0.1", port 35425 failed: FATAL: The password that was provided for the role postgres is wrong.',
+ 'connection failed: connection to server at "10.0.0.1", port 5432 failed: FATAL: The password that was provided for the role posthog_readonly is wrong.',
+ ],
+ )
+ def test_rds_proxy_wrong_password_is_non_retryable(self, source, error_msg):
+ # RDS Proxy's wrong-credentials wording isn't covered by the PostgreSQL "password
+ # authentication failed for user" key, so confirm the dedicated role-password key is what
+ # recognises it, independent of the volatile role name.
+ non_retryable = source.get_non_retryable_errors()
+ assert "The password that was provided for the role" in non_retryable
+ assert "password authentication failed for user" not in error_msg
+ assert any(pattern in error_msg for pattern in non_retryable.keys())
+
def test_supavisor_enotfound_tenant_user_uses_new_key(self, source):
# The older tenant/user patterns don't cover the newer "(ENOTFOUND) tenant/user" wording,
# so confirm it's specifically the new key that recognises this message.