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(mysql): tell a user what to do when the password is rejected (#95571)

Tom Owers7f3a545772a9
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/source.py
index 8cd0dfd77140..39132e5cd29c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/source.py
@@ -76,6 +76,12 @@ _VALIDATE_CONNECTION_HINTS: list[tuple[str, str]] = [
("Unknown database", "Database does not exist. Check the database name is correct."),
]
+# Error 1045 is the same failure the Postgres, Supabase, and Neon sources already word this
+# way. Keeping one wording means a wrong password reads the same whichever database it is.
+_INVALID_CREDENTIALS_ERROR = (
+ "The database rejected the username or password. Check the user and password for this source and try again."
+)
+
_HOST_IS_URL_ERROR = (
"Enter just the hostname in the host field (for example, db.example.com), not a full URL or "
"connection string. Remove any scheme (like http:// or mysql://) and any username, password, "
@@ -200,7 +206,7 @@ class MySQLSource(SQLSource[MySQLSourceConfig], SSHTunnelMixin, ValidateDatabase
# user's host grant) is wrong. Surface it as an auth failure — mirroring the Postgres
# source — so the user fixes credentials instead of the generic "check connection
# details" message sending them to check the host/port.
- "Access denied for user": "Invalid user or password",
+ "Access denied for user": _INVALID_CREDENTIALS_ERROR,
# MySQL/MariaDB error 1049 (ER_BAD_DB_ERROR): the configured database doesn't exist on
# the server — it was renamed or dropped after the source was set up, or the connection
# was reconfigured to point at a different server. `validate_credentials` already
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/tests/test_mysql.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/tests/test_mysql.py
index f8566ff008e0..2139ddf4e415 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/tests/test_mysql.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/tests/test_mysql.py
@@ -45,7 +45,10 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.mysql.mysq
_safe_convert_datetime,
_sanitize_identifier,
)
-from products.warehouse_sources.backend.temporal.data_imports.sources.mysql.source import MySQLSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.mysql.source import (
+ _INVALID_CREDENTIALS_ERROR,
+ MySQLSource,
+)
from products.warehouse_sources.backend.types import IncrementalFieldType
# ---------------------------------------------------------------------------
@@ -2463,7 +2466,7 @@ class TestMySQLSourceValidateCredentials:
# that sends the user to inspect the host/port instead. Mirrors Postgres.
(
pymysql.err.OperationalError(1045, "Access denied for user 'u'@'1.2.3.4' (using password: YES)"),
- "Invalid user or password",
+ _INVALID_CREDENTIALS_ERROR,
),
],
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/planetscale_mysql/test_planetscale_mysql_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/planetscale_mysql/test_planetscale_mysql_source.py
index 56f52ef01b4d..e0fba4bf0d4d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/planetscale_mysql/test_planetscale_mysql_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/planetscale_mysql/test_planetscale_mysql_source.py
@@ -166,7 +166,7 @@ def test_validate_credentials_never_opens_an_ssh_tunnel():
("Connection refused", "port 3306"),
("Can't connect to MySQL server on 'x' (timed out)", "timed out"),
("(1049, \"Unknown database 'x'\")", "does not exist on this PlanetScale branch"),
- ("(1045, \"Access denied for user 'x'\")", "Invalid user or password"),
+ ("(1045, \"Access denied for user 'x'\")", "rejected the username or password"),
("branch is missing or sleeping: abc", "deleted or put to sleep"),
],
)