: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): stop retrying when token_uri is egress-denied (#80182)
Tom Owers91c465e70384
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 339349698226..c8a7a5586936 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@@ -229,6 +229,15 @@ class BigQuerySource(SQLSource[BigQuerySourceConfig]):# user must fix their key file; retrying can't recover. Matched on ngrok's stable# offline-endpoint code rather than the volatile tunnel subdomain in the page."ERR_NGROK_3200": "We couldn't authenticate with BigQuery — your service account key's token_uri points at an offline endpoint, not Google's OAuth token endpoint. Please re-upload your service account key file and verify its token_uri.",+ # A service-account key whose `token_uri` points at a non-globally-routable address+ # (for example a cloud metadata endpoint). PostHog's egress proxy denies the request+ # before it leaves our network and google-auth surfaces that denial as a `RefreshError`+ # naming the proxy's stable rule. The proxy rejects the same non-public host on every+ # retry, so retrying just hammers a request that can never succeed. Google's real OAuth+ # token endpoint is always a public host, so this is a misconfigured `token_uri` — the+ # user must fix their key file. Matched on the proxy's stable rule name rather than the+ # volatile denied host.+ "denied by rule 'Deny: Not Global Unicast'": "We couldn't authenticate with BigQuery — your service account key's token_uri points at an address PostHog can't reach. Please re-upload your service account key file and verify its token_uri is Google's OAuth token endpoint.",# Raised as a `Forbidden` (403, reason `quotaExceeded`) when the customer's BigQuery# project hits an administrator-configured custom cost control, e.g. "Custom quota# exceeded: Your usage exceeded the custom quota for QueryUsagePerDay, which is set bydiff --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 f0c66ce2aeb7..988cc29637ef 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@@ -722,6 +722,28 @@ def test_non_retryable_errors_match_offline_token_uri_endpoint(observed_error):assert all(non_retryable_errors[key] is not None for key in matching)+ "observed_error",+ [+ # token_uri pointed at the cloud metadata endpoint — PostHog's egress proxy denies it.+ "RefreshError: Egress proxying is denied to host '169.254.169.254': no valid IP found "+ "among resolved addresses - 169.254.169.254 denied by rule 'Deny: Not Global Unicast'. .",+ # Different denied host — the match must not rely on the volatile host/IP.+ "RefreshError: Egress proxying is denied to host '10.0.0.5': no valid IP found "+ "among resolved addresses - 10.0.0.5 denied by rule 'Deny: Not Global Unicast'. .",+ ],+)+def test_non_retryable_errors_match_egress_denied_token_uri_endpoint(observed_error):+ """A service account whose `token_uri` points at a non-globally-routable address (e.g. a+ cloud metadata endpoint) makes our egress proxy deny the request, and google-auth surfaces+ that denial as a `RefreshError` — a misconfigured key the user must fix, so the sync must be+ disabled rather than retried forever."""+ non_retryable_errors = BigQuerySource().get_non_retryable_errors()+ matching = [key for key in non_retryable_errors if key in observed_error]+ assert matching, "Egress-denied token_uri endpoint 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",[