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 invalid SSH tunnel auth as non-retryable (#63728)

Tom Owers70b85ca9cfb2
diff --git a/posthog/temporal/data_imports/external_data_job.py b/posthog/temporal/data_imports/external_data_job.py
index 3c2475e1ec5c..3c17ab66c12a 100644
--- a/posthog/temporal/data_imports/external_data_job.py
+++ b/posthog/temporal/data_imports/external_data_job.py
@@ -71,6 +71,15 @@ LOGGER = get_logger(__name__)
Any_Source_Errors: dict[str, str | 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. Shared by every
+ # SSH-capable source (Postgres, Redshift, MySQL, MSSQL, ClickHouse). The auth config is fixed,
+ # so retrying just replays the same invalid credentials; stop and tell the customer to fix it.
+ "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."
+ ),
"Primary key required for incremental syncs": None,
"The primary keys for this table are not unique": None,
"Integration matching query does not exist": "The connected account for this source is no longer available — it may have been disconnected. Please reconnect the source's account.",
diff --git a/posthog/temporal/tests/external_data/test_external_data_job.py b/posthog/temporal/tests/external_data/test_external_data_job.py
index 03a14a02fb4f..f43d21e92a07 100644
--- a/posthog/temporal/tests/external_data/test_external_data_job.py
+++ b/posthog/temporal/tests/external_data/test_external_data_job.py
@@ -586,6 +586,18 @@ async def test_update_external_job_activity_with_tls_handshake_failure_is_non_re
assert schema.should_sync is False
+ "error_msg",
+ [
+ "SSHTunnel auth is not valid",
+ "Exception: SSHTunnel auth is not valid",
+ ],
+)
+def test_invalid_ssh_tunnel_auth_is_non_retryable_for_any_source(error_msg):
+ is_non_retryable = any(pattern in error_msg for pattern in Any_Source_Errors.keys())
+ assert is_non_retryable, f"Invalid SSH tunnel auth error should be non-retryable: {error_msg}"
+
+
@pytest.fixture
def mock_stripe_client():
with mock.patch("posthog.temporal.data_imports.sources.stripe.stripe.StripeClient") as MockStripeClient: