: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(data-imports): stop blaming credentials for a cancelled warehouse query (#76423)
Tom Owersd7f345e541ca
diff --git a/products/warehouse_sources/backend/models/table.py b/products/warehouse_sources/backend/models/table.pyindex fbd22bc1df91..acea21d52e81 100644--- a/products/warehouse_sources/backend/models/table.py+++ b/products/warehouse_sources/backend/models/table.py@@ -30,7 +30,12 @@ from posthog.hogql.escape_sql import escape_clickhouse_identifier, escape_param_from posthog.clickhouse.client import sync_executefrom posthog.clickhouse.query_tagging import Feature, Product, tag_queries-from posthog.errors import CORRUPTED_PARQUET_METADATA_MESSAGE, wrap_clickhouse_query_error+from posthog.errors import (+ CORRUPTED_PARQUET_METADATA_MESSAGE,+ QueryErrorCategory,+ classify_query_error,+ wrap_clickhouse_query_error,+)from posthog.exceptions_capture import capture_exceptionfrom posthog.models.utils import CreatedMetaFields, DeletedMetaFields, UpdatedMetaFields, UUIDTModel, sane_reprfrom posthog.schema_enums import DatabaseSerializedFieldType@@ -932,6 +937,13 @@ class DataWarehouseTable(CreatedMetaFields, UpdatedMetaFields, UUIDTModel, Deletif not hasattr(err, "message"):raise err+ # A cancelled query here means our own client timed out reading, not a bad file or bucket.+ if classify_query_error(err) == QueryErrorCategory.CANCELLED:+ raise Exception(+ "Reading the files from your storage bucket took too long and the query was cancelled. "+ "This is usually temporary - try again, or narrow the URL pattern if the dataset is very large."+ )+for key, value in ExtractErrors.items():if key in raw_message:raise Exception(value)diff --git a/products/warehouse_sources/backend/tests/test_table.py b/products/warehouse_sources/backend/tests/test_table.pyindex b89131ce3241..00cbfd2246be 100644--- a/products/warehouse_sources/backend/tests/test_table.py+++ b/products/warehouse_sources/backend/tests/test_table.py@@ -140,6 +140,11 @@ class TestSafeExposeChError:DataWarehouseTable()._safe_expose_ch_error(err)assert exc_info.value is err+ def test_cancelled_query_gets_a_timeout_message_instead_of_storage_bucket_blame(self) -> None:+ # code 394 QUERY_WAS_CANCELLED here means our own client timed out reading, not bad files.+ with pytest.raises(Exception, match="took too long"):+ DataWarehouseTable()._safe_expose_ch_error(ServerException("DB::Exception: Query was cancelled.", code=394))+def test_delta_kernel_permission_error_gets_actionable_message(self) -> None:# Delta-format tables (the default for every warehouse_sources synced table) read via# ClickHouse's DeltaLake kernel, whose object_store errors use different wording than