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): stop reporting access-denied duplicate-key probe failures as bugs (#124068)

Tom Owersd31139e0472f
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/clickhouse.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/clickhouse.py
index a0bbc40e557d..7a2ba22cf262 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/clickhouse.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/clickhouse.py
@@ -1086,11 +1086,16 @@ _DUPLICATE_PK_CHECK_SETTINGS: dict[str, Any] = {
# - A transient egress-proxy blip (`is_transient_egress_proxy_error`) is our own
# infrastructure being briefly unreachable, not a sign the probe's query itself
# is suspect. Same designed-fallback reasoning as the budget caps above.
+# - ACCESS_DENIED (code 497): the connecting user lacks SELECT on this table. The main
+# extraction query against the same table fails identically and the source already
+# classifies it as a non-retryable customer-config issue (see `get_non_retryable_errors`),
+# so capturing it here too is the same failure reported twice under a different frame.
_EXPECTED_PROBE_FAILURE_SUBSTRINGS: tuple[str, ...] = (
"is unknown or readonly",
"MEMORY_LIMIT_EXCEEDED",
"TIMEOUT_EXCEEDED",
"Read timed out",
+ "ACCESS_DENIED",
)
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 d82b1727996d..dee7b0866c10 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
@@ -783,6 +783,20 @@ class TestHasDuplicatePrimaryKeys:
mock_capture.assert_not_called()
+ def test_access_denied_leaves_key_unverified_without_capturing(self):
+ from products.warehouse_sources.backend.temporal.data_imports.sources.clickhouse import clickhouse as ch_module
+
+ client = MagicMock()
+ client.query.side_effect = ClickHouseError(
+ "Code: 497. DB::Exception: posthog: Not enough privileges. To execute this query, it's necessary "
+ "to have the grant SELECT ON db.t. (ACCESS_DENIED)"
+ )
+
+ with patch.object(ch_module, "capture_exception") as mock_capture:
+ assert _has_duplicate_primary_keys(client, "db", "t", ["id"], self._logger()) is None
+
+ mock_capture.assert_not_called()
+
class TestDuplicateProbeTargetsMergeKey:
_MEMORY_LIMIT = ClickHouseError("Code: 241. DB::Exception: Query memory limit exceeded. (MEMORY_LIMIT_EXCEEDED)")