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(bigquery): treat a deprecated legacy table/view as non-retryable (#106771)

Tom Owersde46f806c1f3
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bigquery/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bigquery/source.py
index 92e09607fac9..3d1c1f6cba0d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bigquery/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bigquery/source.py
@@ -410,6 +410,15 @@ class BigQuerySource(SQLSource[BigQuerySourceConfig]):
# every retry. The user must update the source's column selection to match the table's
# current schema. Matched on the stable wording, not the volatile list of column names.
"do not exist in the table schema": "BigQuery couldn't read this table because it referenced columns that no longer exist on it — usually columns selected for syncing were renamed or removed. Retrying won't help — please update the source's column selection to match the table's current schema, then reconnect the source.",
+ # Raised as a 400 BadRequest from `jobs.getQueryResults` (the same poll `_with_job_not_
+ # found_retry` in `bigquery.py` awaits) when the table or view being synced is guarded by
+ # a deprecation check the customer's own BigQuery team added to it — a query against that
+ # relation deliberately errors to redirect callers to its replacement. It's a deterministic
+ # property of which table the source reads, not of our query shape: the same table fails
+ # identically on every retry until the source is pointed at the replacement. Matched on
+ # BigQuery's stable "Deprecated legacy table/view" wording, not the volatile project name
+ # or job id that surround it.
+ "Deprecated legacy table/view": "BigQuery rejected a query for this source because the table or view it reads has been marked deprecated by your BigQuery team, in favor of a newer replacement. Retrying won't help — please update this source to sync the replacement table or view, then reconnect the source.",
}
def validate_config(self, job_inputs: dict) -> tuple[bool, list[str]]:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bigquery/tests/test_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bigquery/tests/test_source.py
index 3244b71e2ca1..9a05090b2d9e 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bigquery/tests/test_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bigquery/tests/test_source.py
@@ -898,6 +898,28 @@ def test_bigquery_missing_selected_fields_is_non_retryable(observed_error):
assert all(non_retryable_errors[key] is not None for key in matching)
+ "observed_error",
+ [
+ # Raw wording from a customer's own deprecation guard on a legacy table/view.
+ "GET https://bigquery.googleapis.com/bigquery/v2/projects/some-project/queries/"
+ "6c2ee15f-f034-40fa-8af0-49cc721e8367?maxResults=0&location=EU&prettyPrint=false: "
+ "Deprecated legacy table/view. Please migrate to respective new views in `some-project`.",
+ # Different project and job id — the match must not rely on either.
+ "GET https://bigquery.googleapis.com/bigquery/v2/projects/other-project/queries/"
+ "1a2b3c4d-0000-4fcc-a51c-09b2f4237894?maxResults=0&location=US&prettyPrint=false: "
+ "Deprecated legacy table/view. Please migrate to respective new views.",
+ ],
+)
+def test_bigquery_deprecated_legacy_table_is_non_retryable(observed_error):
+ """A table/view guarded by the customer's own deprecation check fails identically on every
+ retry until the source is pointed at the replacement table/view."""
+ non_retryable_errors = BigQuerySource().get_non_retryable_errors()
+ matching = [key for key in non_retryable_errors if key in observed_error]
+ assert matching, "Deprecated legacy table/view error should be recognised as non-retryable"
+ assert all(non_retryable_errors[key] is not None for key in matching)
+
+
@pytest.mark.parametrize(
"observed_error",
[