: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 billingNotEnabled 403 as non-retryable (#63670)
Tom Owersaa75f99957a5
diff --git a/posthog/temporal/data_imports/sources/bigquery/source.py b/posthog/temporal/data_imports/sources/bigquery/source.pyindex 9d845f418643..308c76eb6aac 100644--- a/posthog/temporal/data_imports/sources/bigquery/source.py+++ b/posthog/temporal/data_imports/sources/bigquery/source.py@@ -91,6 +91,10 @@ class BigQuerySource(SQLSource[BigQuerySourceConfig]):# build `project.project.dataset.table` and the client rejects it. It's a deterministic# config error, so retrying never succeeds."table_id must be a fully-qualified ID in standard SQL format": "Your BigQuery Dataset ID looks misconfigured — it should be just the dataset name (for example `analytics`), not `project.dataset`. Please update the Dataset ID in your source configuration.",+ # Forbidden 403 with `reason: billingNotEnabled` — the customer's Google Cloud project+ # has billing disabled (BigQuery sandbox mode), so any query job is rejected before it+ # runs. There's nothing we can do but stop retrying until they enable billing.+ "Billing has not been enabled for this project": "BigQuery billing is not enabled for your Google Cloud project. Enable billing in the Google Cloud console (https://console.cloud.google.com/billing), then resume this source.",# Raised from the shared `evolve_pyarrow_schema` in `pipelines/pipeline/utils.py`# when an integer column's source type was widened (e.g. `INT64` widened from a# narrower numeric type) after the destination table was created with the narrowerdiff --git a/posthog/temporal/data_imports/sources/bigquery/tests/test_source.py b/posthog/temporal/data_imports/sources/bigquery/tests/test_source.pyindex 2ba6d10578ba..779b53ce1b22 100644--- a/posthog/temporal/data_imports/sources/bigquery/tests/test_source.py+++ b/posthog/temporal/data_imports/sources/bigquery/tests/test_source.py@@ -709,3 +709,22 @@ def test_bigquery_storage_read_client_disables_grpc_message_size_limit():options = dict(mock_transport_cls.create_channel.call_args.kwargs["options"])assert options["grpc.max_receive_message_length"] == -1assert options["grpc.max_send_message_length"] == -1+++def test_bigquery_billing_not_enabled_is_non_retryable():+ # A `billingNotEnabled` Forbidden 403 is a customer config issue — retrying never helps.+ # Representative message from a real failed job (the `reason: billingNotEnabled` 403 raised+ # by `job.result()` when the source project has BigQuery billing disabled / is in sandbox mode).+ internal_error = (+ "Forbidden: 403 Billing has not been enabled for this project. Enable billing at "+ "https://console.cloud.google.com/billing. Datasets must have a default expiration time "+ "and default partition expiration time of less than 60 days while in sandbox mode.; "+ "reason: billingNotEnabled, message: Billing has not been enabled for this project."+ )++ non_retryable_errors = BigQuerySource().get_non_retryable_errors()++ billing_key = "Billing has not been enabled for this project"+ assert billing_key in non_retryable_errors, "expected billing key to be non-retryable"+ # Mirror the substring match used by `update_external_data_job_model`.+ assert billing_key in internal_error