: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(clickhouse): treat HTTP 404 from data-warehouse source as non-retryable (#63789)
Tom Owers0231f7c1a86b
diff --git a/posthog/temporal/data_imports/sources/clickhouse/source.py b/posthog/temporal/data_imports/sources/clickhouse/source.pyindex 9d1fdc6c2162..b1ef42045295 100644--- a/posthog/temporal/data_imports/sources/clickhouse/source.py+++ b/posthog/temporal/data_imports/sources/clickhouse/source.py@@ -159,6 +159,14 @@ class ClickHouseSource(SimpleSource[ClickHouseSourceConfig], SSHTunnelMixin, Val"No route to host": None,"certificate verify failed": None,"SSL: WRONG_VERSION_NUMBER": None,+ # clickhouse-connect's HTTP driver got a 404 back while opening the+ # connection ("HTTPDriver for <url> returned response code 404").+ # The host responded but isn't serving the ClickHouse HTTP interface+ # on that path — typically a tunnel/proxy pointing at the wrong+ # service or an offline endpoint. A real ClickHouse server never+ # answers queries with 404, so retrying can't recover. We match only+ # 404, not transient gateway codes (502/503/504), which stay retryable.+ "returned response code 404": "We reached your ClickHouse host but it returned a 404, so it isn't serving the ClickHouse HTTP interface on that host/port. Please check the host, port, and HTTPS setting (and any tunnel or proxy in front of it).",# Raised from the shared `evolve_pyarrow_schema` in `pipelines/pipeline/utils.py`# when an integer column's source type was widened (e.g. `Int32` → `Int64`) after# the destination table was created with the narrower type. Delta Lake can't widendiff --git a/posthog/temporal/data_imports/sources/clickhouse/test_clickhouse.py b/posthog/temporal/data_imports/sources/clickhouse/test_clickhouse.pyindex b4152fec9fbb..e276dfbe5eb1 100644--- a/posthog/temporal/data_imports/sources/clickhouse/test_clickhouse.py+++ b/posthog/temporal/data_imports/sources/clickhouse/test_clickhouse.py@@ -522,6 +522,7 @@ class TestClickHouseSourceNonRetryableErrors:"Could not resolve the ClickHouse host","Connection refused","certificate verify failed",+ "HTTPDriver for https://example.ngrok-free.dev:443 returned response code 404",],)def test_permanent_errors_are_non_retryable(self, source, error_msg):@@ -535,6 +536,9 @@ class TestClickHouseSourceNonRetryableErrors:"Code: 159. DB::Exception: Timeout exceeded", # query timeout — could be retried"Code: 999. DB::Exception: Keeper exception", # transient zookeeper-style errors"Code: 209. DB::Exception: Socket timeout",+ # Transient gateway errors must stay retryable — only 404 is permanent.+ "HTTPDriver for https://example.ngrok-free.dev:443 returned response code 502",+ "HTTPDriver for https://example.ngrok-free.dev:443 returned response code 503",],)def test_transient_errors_are_retryable(self, source, error_msg):