: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(planetscale): stop reporting an exhausted connection retry as a bug during validation (#80160)
Tom Owers1fea9f15f2b9
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/planetscale/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/planetscale/source.pyindex df56db366448..9f1f21650c84 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/planetscale/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/planetscale/source.py@@ -54,6 +54,15 @@ _HOST_NOT_RESOLVED_ERROR = (_GENERIC_CONNECTION_ERROR = "Could not connect to PlanetScale. Please check all connection details are valid."+# `get_schemas` already retried a transient connect-time drop in-process (`_connect_with_transient_retry`+# in mysql.py) before this exhausted every attempt, so the sync path treats the same message as benign via+# `get_retryable_errors` and never reports it. Mirror that here so a brief blip surfaced during interactive+# validation doesn't get captured as an unexpected bug.+_TRANSIENT_CONNECTION_ERROR = (+ "Lost the connection to PlanetScale while checking your credentials. This is usually a brief network "+ "blip rather than a configuration problem. Please try again."+)+# Create-time refinement of pymysql's catch-all connect error (2003), which collapses a bad host,# a closed port, and a firewall drop into one message. Mirrors the MySQL source's handling with# PlanetScale's own guidance. Kept out of `get_non_retryable_errors`, which the sync path also@@ -210,6 +219,9 @@ class PlanetScaleSource(MySQLSource):for pattern, friendly_error in self.get_non_retryable_errors().items():if pattern in error_msg:return False, friendly_error or _GENERIC_CONNECTION_ERROR+ for pattern in self.get_retryable_errors():+ if pattern in error_msg:+ return False, _TRANSIENT_CONNECTION_ERRORcapture_exception(e)return False, _GENERIC_CONNECTION_ERRORdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/planetscale/test_planetscale_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/planetscale/test_planetscale_source.pyindex 1c26ef874ba1..317cb3a98c8a 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/planetscale/test_planetscale_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/planetscale/test_planetscale_source.py@@ -193,6 +193,35 @@ def test_connection_failures_map_to_actionable_messages(raw_error, expected_fragcapture.assert_not_called()+ "raw_error",+ [+ "(2013, 'Lost connection to MySQL server during query')",+ "(1040, 'Too many connections')",+ "(1105, 'reparent operation in progress')",+ ],+)+def test_retryable_sync_errors_are_not_captured_during_validation(raw_error):+ # `get_schemas` already retried these in-process (`_connect_with_transient_retry`) before+ # exhausting its budget and re-raising. The sync path treats them as benign via+ # `get_retryable_errors`; validation must not report them as unexpected bugs either.+ with (+ mock.patch.object(PlanetScaleSource, "is_database_host_valid", return_value=(True, None)),+ mock.patch.object(PlanetScaleSource, "get_schemas", side_effect=Exception(raw_error)),+ mock.patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.planetscale.source.capture_exception"+ ) as capture,+ ):+ success, error = PlanetScaleSource().validate_credentials(_config(), team_id=1)++ assert success is False+ assert error == (+ "Lost the connection to PlanetScale while checking your credentials. This is usually a brief "+ "network blip rather than a configuration problem. Please try again."+ )+ capture.assert_not_called()++def test_unrecognized_failure_is_captured_and_reported_generically():with (mock.patch.object(PlanetScaleSource, "is_database_host_valid", return_value=(True, None)),