: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(bigquery): treat unsupported dataset region as non-retryable (#66388)
Tom Owers249ff3b5afbe
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.pyindex bceb1524f58c..a146e25c3dad 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@@ -106,6 +106,15 @@ class BigQuerySource(SQLSource[BigQuerySourceConfig]):# carrying this exact wording (so the create/validate path shows it instead of the raw# 404). Match it here too so the discovery activity treats it as non-retryable.BIGQUERY_DATASET_NOT_FOUND_ERROR: BIGQUERY_DATASET_NOT_FOUND_ERROR,+ # Raised as a 400 BadRequest from job creation (POST .../jobs) when the location the+ # client runs in — the custom region from the source form, or the dataset's own location+ # auto-detected in `connect` — isn't a region BigQuery can run query jobs in, e.g.+ # "Location ua does not support this operation.". It's a deterministic config problem:+ # retrying the same location always fails identically, so the user must set a valid+ # BigQuery region. The "was not found in location" key only covers a dataset missing from+ # a queried region, not an unsupported region, so this slips through and retries forever.+ # Matched on the stable wording rather than the volatile location code.+ "does not support this operation": "BigQuery rejected the dataset region this source runs in — it isn't a location BigQuery can run queries in. Please set a valid BigQuery region (for example US, EU, or us-east1) in your source configuration, then reconnect the source.",# Raised from `bq_client.get_table(...)` in `_build_source_response` when the table being# synced no longer exists at sync time — it was deleted or renamed in BigQuery (common with# dbt-managed datasets) after schema discovery selected it. The google exception stringifiesdiff --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.pyindex a084ac13d80c..34726b4264c2 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@@ -960,6 +960,31 @@ def test_bigquery_dataset_not_found_in_location_is_non_retryable(location):assert any(pattern in error_msg for pattern in non_retryable_errors)+ "location",+ ["ua", "us-fake1", "EU "],+)+def test_bigquery_unsupported_region_is_non_retryable(location):+ """A custom/auto-detected region BigQuery can't run query jobs in surfaces from job creation as+ a 400 BadRequest whose str() is "... Location <X> does not support this operation.". It's a+ deterministic config error — retrying the same location always fails — so it must be recognised+ as non-retryable via the "does not support this operation" pattern rather than retrying forever.+ The volatile location code must not be part of the match."""+ error_msg = str(+ BadRequest(+ f"POST https://bigquery.googleapis.com/bigquery/v2/projects/my-proj/jobs?prettyPrint=false: "+ f"Location {location} does not support this operation."+ )+ )++ non_retryable_errors = BigQuerySource().get_non_retryable_errors()+ matching = [key for key in non_retryable_errors if key in error_msg]++ assert matching, "an unsupported-region 400 should be recognised as non-retryable"+ assert all(non_retryable_errors[key] is not None for key in matching)+ assert all(location not in key for key in matching), "match must not depend on the volatile location"++def test_bigquery_table_not_found_during_sync_is_non_retryable():"""A table deleted/renamed after schema discovery surfaces from `get_table()` at sync time as agoogle NotFound whose str() is "... Not found: Table <project>:<dataset>.<table>" — distinct from