: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(mssql): stop retrying an ambiguous column name from a stale view (#99657)
Tom Owersfbf417343327
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mssql/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mssql/source.pyindex 27c58af44263..e023f21c3c78 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mssql/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mssql/source.py@@ -111,6 +111,13 @@ class MSSQLSource(SQLSource[MSSQLSourceConfig], SSHTunnelMixin, ValidateDatabase# whose definition selects a column that's no longer present. Fixed source-data shape,# so retrying won't help."Invalid column name": "One of the columns being synced no longer exists in your SQL Server. A column was likely dropped or renamed, or a view's definition references a column that's no longer present. Fix the column or view definition at the source, then re-enable the sync.",+ # SQL Server error 209 — a name in the object we select from resolves to more than one+ # column. Our SELECT reads a single qualified object and only ever names columns+ # discovered from information_schema, so the ambiguity is inside a view body: most often+ # a `SELECT *` over a join that went stale when a base table gained a same-named column.+ # The view keeps failing until it is refreshed or rewritten, so retrying replays the+ # identical 209. Match the stable error text, not the column name that follows it.+ "Ambiguous column name": "A view you're syncing has a column name that exists in more than one of the tables it reads, so SQL Server can't resolve it. Fix or refresh the view definition at the source, then re-enable the sync.",# SQL Server error 245 — an implicit type conversion fails on a specific row's value# (e.g. converting the varchar 'SFDR' to int). Our SELECT does no casts and the# incremental predicate only ever compares like types, so this conversion lives in thediff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mssql/tests/test_mssql.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mssql/tests/test_mssql.pyindex c755a3ee843f..9f461ce9b595 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mssql/tests/test_mssql.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mssql/tests/test_mssql.py@@ -728,6 +728,21 @@ class TestMSSQLSourceNonRetryableErrors:non_retryable = MSSQLSource().get_non_retryable_errors()assert any(pattern in error_msg for pattern in non_retryable.keys()), error_msg+ @pytest.mark.parametrize(+ "error_msg",+ [+ # SQL Server error 209 — a stale view whose body joins two tables that now share a+ # column name. Real pymssql message shape, with the driver's trailing DB-Lib frame.+ "(209, b\"Ambiguous column name 'modified_at'.DB-Lib error message 20018, severity 16:\\n"+ 'General SQL Server error: Check messages from the SQL Server\\n")',+ # Different column name must still match the stable substring.+ "Ambiguous column name 'order_id'.",+ ],+ )+ def test_ambiguous_column_name_is_non_retryable(self, error_msg):+ non_retryable = MSSQLSource().get_non_retryable_errors()+ assert any(pattern in error_msg for pattern in non_retryable.keys()), error_msg+@pytest.mark.parametrize("error_msg",[