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(clickhouse): treat SSH gateway connection failure as non-retryable (#71886)

Tom Owersc6f286a6eb23
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/source.py
index 29003f0aa39c..747aa8fa5ac6 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/source.py
@@ -171,6 +171,14 @@ class ClickHouseSource(SimpleSource[ClickHouseSourceConfig], SSHTunnelMixin, Val
"Code: 192": None, # UNKNOWN_USER
"Code: 497": None, # ACCESS_DENIED
"Authentication failed": None,
+ # Raised by the `sshtunnel` library (via the shared `open_ssh_tunnel` helper) when the
+ # SSH tunnel can't be brought up — the bastion host is unreachable, the host/port is
+ # wrong, the SSH key/credentials are rejected, or a firewall blocks PostHog's IPs. It's
+ # in `Any_Source_Errors`, but the import activity's `_handle_import_error` only consults
+ # this per-source dict, so without the entry a down tunnel retries to the maximum and
+ # reports the customer's gateway misconfig as error-tracking noise. Postgres, MySQL, and
+ # MSSQL already treat this identical error as non-retryable.
+ "Could not establish session to SSH gateway": "Could not connect to your SSH tunnel. Check that the SSH host, port, and credentials are correct, the bastion host is running and reachable, and that PostHog's IP addresses are allowed through its firewall.",
"Could not resolve the ClickHouse host": None,
"nodename nor servname provided": None,
"Name or service not known": None,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/test_clickhouse.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/test_clickhouse.py
index 19168cde3aea..d31d6edd6531 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/test_clickhouse.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/test_clickhouse.py
@@ -646,6 +646,9 @@ class TestClickHouseSourceNonRetryableErrors:
"HTTPDriver for https://host:8443 received ClickHouse error code 50\n Code: 50. "
"DB::Exception: The type 'AggregateFunction(uniq, String)' of a column 'profile_id' "
"is not supported for conversion into Arrow data format: While executing Arrow. (UNKNOWN_TYPE)",
+ # SSH tunnel to the customer's bastion couldn't be brought up — the import path only
+ # checks this per-source dict, so the entry must be here to stop it retrying forever.
+ "Could not establish session to SSH gateway",
],
)
def test_permanent_errors_are_non_retryable(self, source, error_msg):