fix(ci): use a colon-prefixed branch for fork tokenless Codecov uploads - #2363
Merged
Conversation
A real fork PR rebase (gittensory#2496-equivalent traffic) hit "Token required because branch is protected" on the tokenless upload. Per Codecov's own docs, only a branch string with a colon-separated prefix (e.g. forkname:branch) is recognized as unprotected/tokenless-eligible; a bare branch name looks like it could be a real branch on the base repo and gets rejected even with no token configured anywhere. codecov-cli's own auto-detection never adds this prefix (confirmed in its source), so override_branch must supply it explicitly. override_commit/override_pr are unaffected -- the protected-branch check only inspects the branch string.
Contributor
|
Important 🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪 🔍 Gittensory is reviewing…AI analysis is in progress. This comment will update when the review is complete. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed · 🟪 Reviewing |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2363 +/- ##
=======================================
Coverage 95.71% 95.71%
=======================================
Files 222 222
Lines 24655 24655
Branches 8946 8946
=======================================
Hits 23599 23599
Misses 433 433
Partials 623 623 🚀 New features to boost your workflow:
|
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.
Summary
Upload queued for processing failed: {"message":"Token required because branch is protected"}.override_branchwas set to the bare fork branch name (e.g.feat/mcp-block-explorer-feed-filters). Per Codecov's own docs, only a branch string with a colon-separated prefix (e.g.forkname:branch) is recognized as "unprotected" and eligible for a tokenless upload — a bare name looks like it could be a real (possibly protected) branch on the base repo and gets rejected, even with zero token configuration anywhere. Confirmed directly incodecov-cli's source (services/commit/__init__.py):if branch and ":" in branch: ... elif token is None: # protected, warns/rejects.codecov-cli's own auto-detection never adds this prefix either (checkedhelpers/ci_adapters/github_actions.py—_get_branch()returns the bareGITHUB_HEAD_REF), so it has to be supplied explicitly by the caller.override_branchwith the fork owner (${{ github.event.pull_request.head.repo.owner.login }}:${{ github.event.pull_request.head.ref }}) on both fork-tokenless upload steps.override_commit/override_prare untouched — the protected-branch check only inspects the branch string.Why
Follow-up to #2273. The prior fix correctly attributed fork-tokenless uploads to the real PR head sha (closing a misattribution gap flagged by the gate's own AI review), but didn't account for Codecov's separate "is this branch protected" check, which is evaluated purely on the branch string format. This is a live, user-reported failure on an actual contributor PR rebase, not a theoretical concern.
Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.md.Validation
git diff --checknpm run actionlintnpm run test:coveragelocally (nosrc/**lines changed;test/unit/codecov-policy.test.tsupdated with assertions for the colon-prefixed branch format)npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderatetest/unit/codecov-policy.test.tsextended to assert the fork-tokenless steps'override_branchcontains a colon and matches theowner:branchformatSafety