Skip to content

Fix coverage upload for fork pull requests #2006

Closed

Description

@josecelano

Goal

Publish coverage generated by fork pull requests to Codecov without allowing the privileged workflow_run job to check out or execute fork-controlled code.

Problem

Workflow run 29758909096 failed in Upload Coverage Report (PR) with:

Refusing to check out fork pull request code from a 'workflow_run' workflow.

The unprivileged Generate Coverage Report (PR) workflow correctly creates and stores codecov.json, the PR number, and the head SHA as artifacts. The privileged uploader then checks out the artifact-provided head SHA. actions/checkout@v7 correctly blocks that operation for fork pull requests because the job has the base repository's token, secrets, cache scope, and runner access.

This is not a codecov/codecov-action@v7 regression. The Codecov v6-to-v7 upgrade was committed in 709fbec; the workflow behavior was unchanged. The failure appeared after actions/checkout was upgraded from v6 to v7 in ad647c78, which exposes the existing unsafe checkout.

The two-workflow design originated in 9d8174df for #1075, replacing a single pull_request_target workflow that checked out and executed fork code while it could access CODECOV_TOKEN.

Proposed Fix

  1. Check out the trusted default branch before retrieving any fork-produced artifacts, satisfying Codecov's documented checkout prerequisite.
  2. Remove the artifact-provided fork SHA from the checkout configuration.
  3. Keep downloading the coverage report and metadata artifacts, then pass the explicit report path, pull request number, and commit SHA to Codecov.
  4. Do not set allow-unsafe-pr-checkout: true, and do not run or otherwise execute fork-controlled code or artifact content.

Acceptance Criteria

  • A fork-originated pull request completes Upload Coverage Report (PR) and publishes its generated report to Codecov.
  • The privileged uploader checks out only the trusted default branch before artifact retrieval and never checks out or executes fork-controlled code.
  • allow-unsafe-pr-checkout: true is absent.
  • Codecov receives the generated report with the source pull request number and commit SHA.
  • The implementation passes linter all and relevant workflow validation.
  • Fork and same-repository pull request paths are manually verified with recorded workflow and Codecov evidence.

References

Activity

  1. added theissue type on Jul 20, 2026
  2. added
    Bug
    Continuous Integration
    on Jul 20, 2026
  3. self-assigned this
    on Jul 20, 2026
  4. added 2 commits that reference this issue on Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugContinuous Integrationp1

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions