GitHub Actions Coverage Upload Failed? Fix the XML Error

Your Python tests passed, but the GitHub Actions coverage upload failed with this message:

This file is not a Cobertura XML report. Upload a Cobertura XML report.

Start with the file: value in your upload step. Which command created that file? If it was pytest --junitxml=coverage.xml, you’ve found the problem. Despite its name, the file contains test results. GitHub’s coverage action expects a report showing which lines of your code ran during those tests.

This fix applies to actions/upload-code-coverage in repositories with GitHub Code Quality enabled on GitHub Team or GitHub Enterprise Cloud. The example below uses Python, pytest, and coverage.py.

Why did the upload start failing?

On November 23, 2026, GitHub added a format check to its coverage upload action. Before that change, an unsupported file could appear to upload successfully while the pull request showed no coverage. The action now reports the format error in the workflow log. Read GitHub’s announcement.

Generate the right XML report from your Python tests

A JUnit report tells you which tests passed. A Cobertura report tells you which lines those tests exercised. If your project uses both, give the files distinct names so it’s clear which one to upload.

In your existing Python test job, make sure your project dependencies, pytest, and coverage are installed. Replace the current pytest step with this one. It runs the test suite once and produces both reports:

- name: Run tests and generate coverage
  run: |
    python -m coverage run -m pytest --junitxml=test-results.xml
    python -m coverage xml -o coverage.xml
  • test-results.xml contains pytest results. Keep it for any tool that reads JUnit reports.
  • coverage.xml contains line coverage in Cobertura format. This is the file to send to GitHub.

If your project already defines which source files to measure in .coveragerc or pyproject.toml, keep those settings. See how coverage.py generates Cobertura XML.

Point the GitHub Actions upload step at coverage.xml

Add this step after report generation in the same job. The example assumes the report was written at the repository root:

- name: Upload Python code coverage
  if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
  uses: actions/upload-code-coverage@v1
  with:
    file: coverage.xml
    language: Python
    label: code-coverage/pytest

Check the directory. If your test step runs in backend/, the report may be at backend/coverage.xml. Use that path in file:. This matters in repositories where several projects each generate a file named coverage.xml.

The upload job also needs the code-quality: write permission. The condition in this example skips uploads from fork pull requests. Use a branch in the same repository to verify the setup. See the full GitHub Actions coverage workflow and its permissions.

Confirm that coverage appears on the pull request

Push a commit to your test branch and open the workflow run. Check that the report-generation step completed and the upload step ran. Then open the pull request and look for the coverage summary from github-code-quality[bot].

  • Still seeing the Cobertura error? Trace the uploaded file back to the command that wrote it. Check whether a later step overwrote it with a JUnit report.
  • File missing? Compare the report’s output directory with the upload step’s file: path.
  • Upload skipped? Check whether the pull request came from a fork and whether the step’s condition allowed it to run.

If the job itself stays queued and none of these steps produce logs, start with how to diagnose a GitHub Actions job stuck in queue.

About the author

Kiran Sonawane

Kiran Sonawane is a DevOps engineer who works with AWS, Azure, Google Cloud, Terraform, and Kubernetes. His experience includes automating infrastructure, managing CI/CD pipelines, securing cloud environments, and deploying AI applications. At Staging Notes, he writes practical guides that help small teams troubleshoot deployments and manage their cloud infrastructure.