: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): say which field to fix when the database is unknown (#97207)
Tom Owers2f9fc8b9909a
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.pyindex 89304ae7d1f8..ea135f68542d 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@@ -90,7 +90,7 @@ _REDIRECTED = (ClickHouseErrors: dict[str, str] = {"authentication failed": "Invalid user or password","code: 516": "Invalid user or password", # AUTHENTICATION_FAILED- "code: 81": "Database does not exist", # UNKNOWN_DATABASE+ "code: 81": "Database does not exist. Check the database name is correct.", # UNKNOWN_DATABASE"code: 60": "Table does not exist", # UNKNOWN_TABLE"code: 192": "Permission denied on the requested database or table", # UNKNOWN_USER"code: 497": "Permission denied on the requested database or table", # ACCESS_DENIEDdiff --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.pyindex ed31dd5331d9..e39789b93019 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@@ -1015,6 +1015,12 @@ class TestTranslateError:msg = "Code: 516. DB::Exception: Authentication failed for user 'default'"assert ClickHouseSource._translate_error(msg) == "Invalid user or password"+ def test_unknown_database_names_the_field_to_fix(self):+ # A wrong database name is the common cause, so the message must point at that field+ # rather than leaving the user to guess between the database, the host, and permissions.+ msg = "Code: 81. DB::Exception: Database analytics does not exist"+ assert ClickHouseSource._translate_error(msg) == "Database does not exist. Check the database name is correct."+def test_returns_none_for_unrecognised_error(self):assert ClickHouseSource._translate_error("Some random error") is None