: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): treat invalid SSH tunnel auth as non-retryable (#64649)
Tom Owersae8f0c1aab80
diff --git a/posthog/temporal/data_imports/sources/postgres/source.py b/posthog/temporal/data_imports/sources/postgres/source.pyindex 2b7c5871b459..358b7cb86c9a 100644--- a/posthog/temporal/data_imports/sources/postgres/source.py+++ b/posthog/temporal/data_imports/sources/postgres/source.py@@ -379,6 +379,17 @@ class PostgresSource(SQLSource[PostgresSourceConfig], SSHTunnelMixin, ValidateDa"SSLRequiredError": None,"SSL/TLS connection is required": None,"Could not establish session to SSH gateway": None,+ # Raised by `SSHTunnel.get_tunnel` when `is_auth_valid()` fails — the SSH tunnel private+ # key can't be parsed, or password auth is missing a username/password. The auth config+ # is fixed, so retrying just replays the same invalid credentials. The streaming path+ # already classifies this via `Any_Source_Errors`, but schema discovery only consults+ # the per-source dict, so without this entry discovery keeps retrying and reporting the+ # customer's misconfig as error-tracking noise on every run.+ "SSHTunnel auth is not valid": (+ "Your SSH tunnel credentials are not valid. Check the SSH authentication details "+ "(private key, passphrase, or username and password) on the source's SSH tunnel "+ "configuration, then re-enable the sync."+ ),"server login has been failing": ("Your database's connection pooler (for example PgBouncer) reported that it has "'repeatedly failed to connect to the backend database ("server login has been 'diff --git a/posthog/temporal/data_imports/sources/postgres/test_postgres.py b/posthog/temporal/data_imports/sources/postgres/test_postgres.pyindex c14234e04ddc..71699849d4d6 100644--- a/posthog/temporal/data_imports/sources/postgres/test_postgres.py+++ b/posthog/temporal/data_imports/sources/postgres/test_postgres.py@@ -345,6 +345,27 @@ class TestPostgresSourceNonRetryableErrors:is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())assert is_non_retryable, f"TLS ALPN rejection error should be non-retryable: {error_msg}"+ @pytest.mark.parametrize(+ "error_msg",+ [+ "SSHTunnel auth is not valid",+ # Temporal-wrapped form carrying the exception class name.+ "Exception: SSHTunnel auth is not valid",+ ],+ )+ def test_invalid_ssh_tunnel_auth_is_non_retryable(self, source, error_msg):+ non_retryable = source.get_non_retryable_errors()+ assert "SSHTunnel auth is not valid" in non_retryable+ is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())+ assert is_non_retryable, f"Invalid SSH tunnel auth error should be non-retryable: {error_msg}"++ def test_invalid_ssh_tunnel_auth_returns_friendly_message(self, source):+ non_retryable = source.get_non_retryable_errors()+ error_msg = "SSHTunnel auth is not valid"+ friendly = [reason for pattern, reason in non_retryable.items() if pattern in error_msg and reason]+ assert friendly, "Invalid SSH tunnel auth error should surface an actionable message"+ assert "SSH authentication details" in friendly[0]+def test_tls_no_application_protocol_returns_friendly_message(self, source):non_retryable = source.get_non_retryable_errors()error_msg = (