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): say what to check when the login is rejected (#104240)

Tom Owersc37e563cfedb
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 1b445ec114f9..696f22f422d7 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
@@ -85,11 +85,17 @@ _REDIRECTED = (
"ClickHouse HTTP interface directly rather than at a proxy or load balancer in front of it."
)
+# Matches the wording the other database sources use for a rejected login, so the same
+# problem reads the same way across Postgres, MySQL and ClickHouse.
+_INVALID_CREDENTIALS = (
+ "The database rejected the username or password. Check the user and password for this source and try again."
+)
+
# Error message → user-friendly translation. Matched as a substring of the
# exception string. Patterns are lowercase-matched.
ClickHouseErrors: dict[str, str] = {
- "authentication failed": "Invalid user or password",
- "code: 516": "Invalid user or password", # AUTHENTICATION_FAILED
+ "authentication failed": _INVALID_CREDENTIALS,
+ "code: 516": _INVALID_CREDENTIALS, # AUTHENTICATION_FAILED
"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
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 aa37c00c27ce..b3678f7827b2 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
@@ -1000,7 +1000,9 @@ class TestGetClientSessionSettings:
class TestTranslateError:
def test_matches_substring_inside_long_error(self):
msg = "Code: 516. DB::Exception: Authentication failed for user 'default'"
- assert ClickHouseSource._translate_error(msg) == "Invalid user or password"
+ translated = ClickHouseSource._translate_error(msg)
+ assert translated is not None
+ assert "rejected the username or password" in translated
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
@@ -1194,7 +1196,7 @@ class TestSourceClassValidateCredentials:
valid, msg = source.validate_credentials(config, team_id=1)
assert valid is False
- assert msg == "Invalid user or password"
+ assert msg is not None and "rejected the username or password" in msg
def test_url_in_host_field_returns_actionable_message_without_reflecting_input(self):
from products.warehouse_sources.backend.temporal.data_imports.sources.clickhouse import source as source_module