Skip to content
Latchkey

SonarQube coverage report not imported / 0% coverage in CI

Sonar reports 0% coverage because the coverage report was never imported: the reportPaths property pointed to a missing file, a wrong format, or paths the scanner could not match to source files.

What this error means

Sonar shows 0% coverage despite passing tests, and the log warns "Coverage report ... could not be read" or "cannot resolve the file path ... of the coverage report."

SonarQube
WARN: Could not resolve 70 file paths in [coverage.xml], first unresolved path:
src/app/main.py (report path: coverage.xml)

Common causes

reportPaths points at a missing or wrong file

The coverage file was not generated before the scan, or the property names a path that does not exist in the job.

Report paths do not match scanned sources

Relative paths in the coverage XML do not resolve against sonar.sources, so Sonar cannot attribute coverage to files.

How to fix it

Generate coverage, then point Sonar at it

  1. Produce the coverage report in the format Sonar expects for your language.
  2. Set the language-specific reportPaths property to that file.
  3. Run the scan after the report exists and confirm coverage is non-zero.
sonar-project.properties
# sonar-project.properties
sonar.sources=src
sonar.python.coverage.reportPaths=coverage.xml

Align coverage paths with sonar.sources

Generate coverage from the repository root so report paths resolve against the scanned source directory.

Terminal
coverage run -m pytest && coverage xml -o coverage.xml

How to prevent it

  • Run the test/coverage step before the Sonar scan.
  • Use the correct reportPaths property for each language.
  • Keep coverage paths relative to the repository root.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →