: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(mysql): stop reporting best-effort EXPLAIN failures to error tracking (#63710)
Tom Owers8685ee1a2756
diff --git a/posthog/temporal/data_imports/sources/mysql/mysql.py b/posthog/temporal/data_imports/sources/mysql/mysql.pyindex 47b011fbe10f..771e81d228ea 100644--- a/posthog/temporal/data_imports/sources/mysql/mysql.py+++ b/posthog/temporal/data_imports/sources/mysql/mysql.py@@ -779,8 +779,13 @@ class MySQLImplementation(SQLSourceImplementation[MySQLSourceConfig, pymysql.Conexplain_lines = [str(dict(zip(column_names, row))) for row in rows]logger.debug(f"EXPLAIN result: {' | '.join(explain_lines) if explain_lines else '(empty)'}")except Exception as e:+ # EXPLAIN is best-effort diagnostics; its failure never affects the+ # sync (the streaming query runs right after regardless). Capturing+ # here just floods error tracking with benign, non-actionable noise —+ # e.g. MySQL 1345 when EXPLAINing a view whose underlying tables the+ # connected user lacks SHOW VIEW on. Debug-log only, like+ # `find_index_for_cursor`.logger.debug(f"EXPLAIN raised an exception: {e}", exc_info=e)- capture_exception(e)# ------------------------------------------------------------------# Pipeline build — the dlt `SourceResponse` for a single tablediff --git a/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py b/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.pyindex 61ab3800a29c..d6ffb2107d36 100644--- a/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py+++ b/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py@@ -517,6 +517,17 @@ class TestExplainQuery:# Must not raise — diagnostic-only.impl.explain_query(cursor, "SELECT 1", {}, logger)+ def test_does_not_capture_exceptions(self, impl, cursor, logger, mocker):+ # EXPLAIN is best-effort diagnostics — a failure (e.g. MySQL 1345 when+ # EXPLAINing a view whose underlying tables the user can't SHOW VIEW on)+ # never affects the sync, so it must not be reported to error tracking.+ capture = mocker.patch("posthog.temporal.data_imports.sources.mysql.mysql.capture_exception")+ cursor.execute.side_effect = pymysql.err.OperationalError(+ 1345, "EXPLAIN/SHOW can not be issued; lacking privileges for underlying table"+ )+ impl.explain_query(cursor, "SELECT 1", {}, logger)+ capture.assert_not_called()+class TestSafetyContract:"""Verifies that driver-specific metadata queries never splice untrusted identifiers into SQL."""