Skip to content
← Back to activity

Solution skill

v5 token-required error on Dependabot PRs: add token to Dependabot secrets

Version 2Sign in to save

Complete solution

Shows how to fix v5 token-required error on Dependabot PRs: add token to Dependabot secrets. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Issue codecov/codecov-action#1653 (closed, 32 comments): v5 upgrade gives new error 'token required because branch is protected'.

Steps

  1. Issue codecov/codecov-action#1653 (closed, 32 comments): v5 upgrade gives new error 'token required because branch is protected'. PR upgrading from v4 to v5 has a token in the secrets, but with v5 it fails with the branch-protection error.
  2. [thomasrockhu-codecov (commenter)]: If codecov-action v5 fails on Dependabot PRs with "token required because branch is protected" even though the token is in your repo secrets, add CODECOV_TOKEN to your Dependabot secrets too (repo Settings, Secrets and variables, Dependabot). v5 reads the token differently and Dependabot PRs do not inherit regular repository secrets, so the protected-branch check fails without it.

When to use

You are seeing this: PR upgrading from v4 to v5 has a token in the secrets, but with v5 it fails with the branch-protection error. Use this skill when you run into "v5 token-required error on Dependabot PRs: add token to Dependabot secrets".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

Issue codecov/codecov-action#1653 (closed, 32 comments): v5 upgrade gives new error 'token required because branch is protected'.

Sources

  • https://github.com/codecov/codecov-action/issues/1653

Evidence

In https://github.com/codecov/codecov-action/issues/1653, the reporter asked: Issue codecov/codecov-action#1653 (closed, 32 comments): v5 upgrade gives new error 'token required because branch is protected'. PR upgrading from v4 to v5 has a token in the secrets, but with v5 it fails with the branch-protection error. The verified answer: [thomasrockhu-codecov (commenter)]: If codecov-action v5 fails on Dependabot PRs with "token required because branch is protected" even though the token is in your repo secrets, add CODECOV_TOKEN to your Dependabot secrets too (repo Settings, Secrets and variables, Dependabot). v5 reads the token differently and Dependabot PRs do not inherit regular repository secrets, so the protected-branch check fails without it. Source thread: https://github.com/codecov/codecov-action/issues/1653

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_NdA_kCjRgunn082-S_ZQxw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">v5 token-required error on Dependabot PRs: add token to Dependabot secrets <span>— Vectle</span></a>

v5 token-required error on Dependabot PRs: add token to Dependabot secrets | Vectle