Send product User-Agent on backend calls to clear Cloudflare BIC#56
Merged
Conversation
Server-mode broker calls used Python's default Python-urllib/x.y User-Agent, which Cloudflare's Browser Integrity Check 403s (error 1010) at the edge before the Worker runs. server_claim_queue saw the 403 and claimed nothing, for every repo, silently for ~24h. Send User-Agent: CI-Scope-Broker/1.0 (overridable via CI_SCOPE_USER_AGENT) from the single backend_request() chokepoint, covering heartbeat, claim, snapshot, and SSE. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (RC#1)
A server-mode broker (
CI_SCOPE_SERVER_MODE=1) claimed no jobs for any repo for ~24h.moodlingPR #66 sat queued, runner=none.Root cause: every backend call in
backend_request()used Python's defaultPython-urllib/x.yUser-Agent. Cloudflare's Browser Integrity Check bans that UA with 403, error code 1010, at the edge — before the Worker runs.server_claim_queuerecorded the 403 and returned nothing. Because it's UA-based, it hit every repo.Proof — identical request, UA the only variable:
Python-urllib/3.11→ 403, error 1010,server: cloudflareFix
backend_request()(the single chokepoint for heartbeat, claim, snapshot, and SSE) now sendsUser-Agent: CI-Scope-Broker/1.0, overridable viaCI_SCOPE_USER_AGENT. Patching the UA locally flipped 403 → 401, confirming the edge clears.New test:
test_backend_request_sends_non_bot_user_agent. All 10 broker tests pass.Not in this PR (need decisions / server side)
401 authentication_required, which the server-queue Worker doesn't emit (it returnsinvalid_token), and the broker calls/v1/snapshot+/v1/events/streamwhich that Worker lacks. Deployedci.forkhorizon.comis a different build than this branch. Needs: confirm what's deployed, reconcileCI_SCOPE_BACKEND_TOKEN↔ backendCI_SCOPE_LOCAL_TOKEN, align/v1/*vs/api/ci/local/*.CI_SCOPE_MACHINE_LABELS; whether the backend should fan per-repo labels to brokers is a design call.backend.connected=false > N min(status is already persisted); unbuilt pending a yes.🤖 Generated with Claude Code