Anthropic and Gemini models polls fail on caller location when the cron runs in an unsupported region #356
Follow-up to #352. #353 now quotes the provider's reason in fetch errors, and the reasons confirm the location hypothesis.
Evidence (PostHog ingest_failed, job models-poll)#
| provider | error | events since #353 deploy |
|---|---|---|
| gemini | GET /v1beta/models?pageSize=1000 → 400 Bad Request: {"error":{"code":400,"message":"User location is not supported for the API use.","status":"FAILED_PRECONDITION"}} | 4 |
| anthropic | GET /v1/models?limit=100 → 403 Forbidden: {"error":{"type":"forbidden","message":"Request not allowed"}} | 4 |
Failing poll slots (UTC, 2026-10-19), always both providers together: 12:15, 13:45, 14:00, 14:15. That is 4 of the 9 polls from 12:15 to 14:15. The polls in between succeed with the same keys. Before #353 the same pair failed together on 2026-10-18 at 15:00, 15:45, 16:00 and 18:30.
Gemini's message names location directly. Anthropic's forbidden / Request not allowed is the response it gives for unsupported regions. Both fail in the same invocation and pass in the next one, so the cause is where that invocation runs.
Why there is no small code fix#
Cron Triggers run on whatever Cloudflare machines have spare capacity, not near any region. placement (Smart Placement or placement.region) only affects fetch handlers, so adding it to wrangler.jsonc does not move the scheduled() poll. Swallowing or downgrading these errors would only hide them, so this run leaves the code as it is.
Options (needs a decision)#
- Placed egress Worker. Add a small Worker with
placement.region(for examplegcp:us-central1) behind a service binding, and send the provider fetches for location-gated APIs through its fetch handler. This fixes the cause, but it adds a deploy unit. - Cron calls our own placed fetch route. Give this Worker a
placement.region, and havescheduled()hand the models poll to an admin-keyed fetch route on itself. There is less new infrastructure, but the poll then counts against request limits and needs auth. - Gather evidence first. Record the invocation's colo (for example from
https://www.cloudflare.com/cdn-cgi/trace) oningest_failedevents, so we can see which colos fail before choosing.
Impact today: no stored rows are lost, because a failed poll leaves rows unchanged and the next poll refreshes them. But about 40% of polls for two major providers are failing, and the rate is rising.
tombeckenham closed this
Sign in to join this conversation.