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(warehouse-sources): stop retrying TiDB Cloud access-denied errors (#98909)

Tom Owers2587358d1096
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 5837879427d9..16b826d2b9e7 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
@@ -226,6 +226,19 @@ class MySQLSource(SQLSource[MySQLSourceConfig], SSHTunnelMixin, ValidateDatabase
# 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_CREDENTIALS_ERROR,
+ # TiDB Cloud's own ER_ACCESS_DENIED_ERROR (also 1105) wording, distinct from the
+ # standard MySQL "Access denied for user" text above: it points the user at TiDB
+ # Cloud's docs on the cluster-tier username prefix a Serverless cluster requires
+ # (e.g. `<prefix>.root`). Same root cause — wrong credentials, or a username missing
+ # that prefix — so it's non-retryable for the same reason, but needs its own key since
+ # neither existing "Access denied" phrase appears in it. Match the stable sentence,
+ # excluding TiDB's own docs URL that follows it.
+ "Access denied. Please check your user name and password": (
+ "TiDB Cloud rejected the username or password. If you're connecting to a TiDB "
+ "Cloud Serverless cluster, make sure your username includes the required cluster "
+ "prefix (see TiDB Cloud's connection docs). Otherwise check the user and password "
+ "for this source and try again."
+ ),
# 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 350717690d57..d9dacb1ec752 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
@@ -2058,6 +2058,22 @@ class TestMySQLSourceNonRetryableErrors:
assert friendly is not None, f"Connect failure should surface a friendly message: {error_msg}"
assert "SSH tunnel" in friendly
+ def test_tidb_cloud_access_denied_surfaces_actionable_message(self, source):
+ # TiDB Cloud's ER_ACCESS_DENIED_ERROR wording doesn't contain the standard MySQL
+ # "Access denied for user" phrase, so without its own entry this credentials failure
+ # would retry forever instead of surfacing the cluster-tier username prefix guidance.
+ error_msg = (
+ "(1105, 'Access denied. Please check your user name and password. See "
+ "https://docs.pingcap.com/tidbcloud/select-cluster-tier#user-name-prefix')"
+ )
+ non_retryable = source.get_non_retryable_errors()
+ friendly = next(
+ (message for pattern, message in non_retryable.items() if pattern in error_msg),
+ None,
+ )
+ assert friendly is not None, f"TiDB Cloud access-denied error should be non-retryable: {error_msg}"
+ assert "TiDB Cloud" in friendly
+
@pytest.mark.parametrize(
"error_msg",
[