# Error parsing python coverage

**URL:** <https://community.sonarsource.com/t/error-parsing-python-coverage/138531>\
**Category:** SonarQube Server / Community Build\
**Tags:** github-actions, python, coverage\
**Created:** [April 9, 2025, 10:00am UTC](https://community.sonarsource.com/t/error-parsing-python-coverage/138531 "2025-04-09T10:00:35Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ggsdc](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ggsdc/32/68704_2.png) [@ggsdc](https://community.sonarsource.com/u/ggsdc)\
**Post date:** [April 9, 2025, 10:00am UTC](https://community.sonarsource.com/t/error-parsing-python-coverage/138531/1 "2025-04-09T10:00:35Z")

</div>

Must-share information (formatted with [Markdown](https://commonmark.org/help/)):

- which versions are you using (SonarQube Server / Community Build, Scanner, Plugin, and any relevant extension): Community Build v25.2.0.102705

So I have a public repo: [GitHub - baobabsoluciones/cornflow: An open source multi-solver optimization server with a REST API.](https://github.com/baobabsoluciones/cornflow/)

Where I have the following Github action: [cornflow/.github/workflows/sonarqube.yml at develop · baobabsoluciones/cornflow · GitHub](https://github.com/baobabsoluciones/cornflow/blob/develop/.github/workflows/sonarqube.yml)

This actions runs three different test suites and uploads their respective coverage reports as an artifact to be then downloaded and uploaded with the sonarqube scan action.

For that I have the following sonar-project.properties file:

```auto
# Project identification
sonar.projectKey=cornflow
sonar.projectVersion=1.0

# Source code location
sonar.sources=cornflow-dags,cornflow-server,libs
sonar.tests=cornflow-server/cornflow/tests,cornflow-dags/tests,libs/client/cornflow_client/tests

# Encoding of source files
sonar.sourceEncoding=UTF-8

# Coverage settings
sonar.python.coverage.reportPaths=coverage-server.xml,coverage-client.xml,coverage-dags.xml

# Python specific settings
sonar.python.version=3

# Exclusions
sonar.exclusions= **/ __pycache__ /** , **/*.pyc,** /venv/ **,** /.env/ **,docs/** , **/tests/**

```

When running the last job of the action I get the downloaded artifacts:

```auto
Found 3 artifact(s)
Filtering artifacts by pattern 'coverage-*.xml'
Preparing to download the following artifacts:
- coverage-client.xml (ID: 2905358904, Size: 5923, Expected Digest: sha256:113ae8d8f1e79e37bf3cc7fc3e419422883c6b9022038d7f12caf1f52c915c21)
- coverage-server.xml (ID: 2905312944, Size: 15019, Expected Digest: sha256:b3d67a6b482aa025741b4b446b46895adf69ddafc2e7c41526755292459f86b2)
- coverage-dags.xml (ID: 2905276006, Size: 19420, Expected Digest: sha256:00f9a57e44dddc590cc6a773ef5f095973d30d77bebde8148e4d1679b0037c33)
Redirecting to blob download url: https://productionresultssa13.blob.core.windows.net/actions-results/ba2047cc-f6c5-44ff-8b7b-e91555748a38/workflow-job-run-892519c9-2193-5677-6fbc-81aa76fa971a/artifacts/cca311c9bec5fc010c399b7408badcf85c3f218aff427b1c37af8d0b5d640195.zip
Starting download of artifact to: /home/runner/work/cornflow/cornflow/coverage-client.xml
Redirecting to blob download url: https://productionresultssa13.blob.core.windows.net/actions-results/0eb1a61b-60e9-4fae-a954-7401421df54e/workflow-job-run-8a0296dd-f818-5bdb-4cfb-a6b2ce09069b/artifacts/55b17eb6713003f3c7dd85e7d30a6f70ec6c365bcb0a450e12abbc3d8dd3a057.zip
Starting download of artifact to: /home/runner/work/cornflow/cornflow/coverage-server.xml
(node:1830) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Redirecting to blob download url: https://productionresultssa13.blob.core.windows.net/actions-results/0eb1a61b-60e9-4fae-a954-7401421df54e/workflow-job-run-ebc41999-9411-5e91-bb01-028bb8fcecc8/artifacts/9cdfefe77bba3ca16e4d1ad2030b7ac81fe9d894ed3094a25690555614882473.zip
Starting download of artifact to: /home/runner/work/cornflow/cornflow/coverage-dags.xml

```

And then I get the following warning on the sonarqube scan:

```auto
18:02:15.384 INFO Python test coverage
18:02:15.385 INFO Parsing report '/home/runner/work/cornflow/cornflow/coverage-server.xml'
18:02:15.395 WARN Cannot read coverage report '/home/runner/work/cornflow/cornflow/coverage-server.xml', the following exception occurred: 'Error parsing the report '/home/runner/work/cornflow/cornflow/coverage-server.xml''
18:02:15.395 INFO Parsing report '/home/runner/work/cornflow/cornflow/coverage-client.xml'
18:02:15.395 WARN Cannot read coverage report '/home/runner/work/cornflow/cornflow/coverage-client.xml', the following exception occurred: 'Error parsing the report '/home/runner/work/cornflow/cornflow/coverage-client.xml''
18:02:15.395 INFO Parsing report '/home/runner/work/cornflow/cornflow/coverage-dags.xml'
18:02:15.396 WARN Cannot read coverage report '/home/runner/work/cornflow/cornflow/coverage-dags.xml', the following exception occurred: 'Error parsing the report '/home/runner/work/cornflow/cornflow/coverage-dags.xml''
18:02:15.396 INFO Sensor Cobertura Sensor for Python coverage [python] (done) | time=64ms

```

I have attached one of the coverage reports so that it can be checked as well, but, why does the sonarqube scan action fail to parse the report? How can I get more informaton about the error?  
[coverage-client.xml.zip](https://community.sonarsource.com/uploads/short-url/uc8ESouuzFMQPONqNRkZvYfrmTW.zip) (5.8 KB)

EDIT: I have run the github action with loglevel DEBUG and verbose=true and the log does not contain more information about why the warning is getting raised and the coverage report can not be read.

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [April 10, 2025, 6:40pm UTC](https://community.sonarsource.com/t/error-parsing-python-coverage/138531/2 "2025-04-10T18:40:42Z")

</div>

Hi,

Welcome to the community!

> [@ggsdc](#):
>
> I have run the github action with loglevel DEBUG and verbose=true and the log does not contain more information

To be clear, did you get `DEBUG`-level logging out of analysis itself? I’m trying to distinguish here between debug GHActions logging and debug analysis logging.

&nbsp;  
Thx,  
Ann

---

<div class="post-metadata">

**Author:** ![ggsdc](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ggsdc/32/68704_2.png) [@ggsdc](https://community.sonarsource.com/u/ggsdc)\
**Post date:** [April 10, 2025, 6:57pm UTC](https://community.sonarsource.com/t/error-parsing-python-coverage/138531/3 "2025-04-10T18:57:34Z")

</div>

> [@ganncamp](#):
>
> To be clear, did you get `DEBUG`-level logging out of analysis itself? I’m trying to distinguish here between debug GHActions logging and debug analysis logging.

I setted up these parameters on my sonar-project.properties file:

```auto
# Sonnar logging level
sonar.log.level=DEBUG

# Verbose logging
sonar.verbose=true

```

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [April 10, 2025, 7:04pm UTC](https://community.sonarsource.com/t/error-parsing-python-coverage/138531/5 "2025-04-10T19:04:08Z")

</div>

Hi,

Thanks for confirming. Could you post the full, `DEBUG` analysis log (even tho there’s no extra data), redacted as necessary?

Since `DEBUG` was no help, I’m not sure where to go from here, so I’ve flagged this for the experts, and they’ll want to have it available.

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![ggsdc](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ggsdc/32/68704_2.png) [@ggsdc](https://community.sonarsource.com/u/ggsdc)\
**Post date:** [April 10, 2025, 7:08pm UTC](https://community.sonarsource.com/t/error-parsing-python-coverage/138531/6 "2025-04-10T19:08:21Z")

</div>

> [@ganncamp](#):
>
> Thanks for confirming. Could you post the full, `DEBUG` analysis log (even tho there’s no extra data), redacted as necessary?

Sure thing, as the logs are too big I have attached them on a zip file.  
[logs\_36984628980.zip](https://community.sonarsource.com/uploads/short-url/vFDPMVjwl8cfBxujN6tl3APtQth.zip) (37.1 KB)

Please let me know if there is any extra information that I can provide that can be of help, the github action run is here: [Corrected a bunch of more issues (#631) · baobabsoluciones/cornflow@0dd4d06 · GitHub](https://github.com/baobabsoluciones/cornflow/actions/runs/14381231943/job/40325943705)

---

<div class="post-metadata">

**Author:** ![Guillaume\_Dequenne](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/guillaume_dequenne/32/7472_2.png) [@Guillaume\_Dequenne](https://community.sonarsource.com/u/Guillaume_Dequenne)\
**Post date:** [April 16, 2025, 1:52pm UTC](https://community.sonarsource.com/t/error-parsing-python-coverage/138531/8 "2025-04-16T13:52:37Z")

</div>

Hello @ggsdc and sorry for the late answer.

I must admit I am a bit puzzled by this issue. I have tested the coverage file you provided against our parser directly, as well as on a local instance of SonarQube, and the file got parsed without problem.

In order to troubleshoot this, could you try as well to import this report on a local instance of SonarQube and let me know if you still encounter the parse error? If you can’t reproduce the parse error locally, can you generate another file that does trigger this parse error? My assumption at this point would be that the file as it is imported is not the same as the one generated. Generally, what can happen in the context of GitHub Actions is that paths are inconsistent, but this wouldn’t lead to a parse error.

Cheers,  
Guillaume

---

<div class="post-metadata">

**Author:** ![ggsdc](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ggsdc/32/68704_2.png) [@ggsdc](https://community.sonarsource.com/u/ggsdc)\
**Post date:** [April 17, 2025, 2:31pm UTC](https://community.sonarsource.com/t/error-parsing-python-coverage/138531/9 "2025-04-17T14:31:28Z")

</div>

> [@Guillaume\_Dequenne](#):
>
> In order to troubleshoot this, could you try as well to import this report on a local instance of SonarQube and let me know if you still encounter the parse error? If you can’t reproduce the parse error locally, can you generate another file that does trigger this parse error? My assumption at this point would be that the file as it is imported is not the same as the one generated. Generally, what can happen in the context of GitHub Actions is that paths are inconsistent, but this wouldn’t lead to a parse error.

Hi, attached you can find the three separate coverage reports that fail on the Github Actions process.

[coverage-dags.xml.zip](https://community.sonarsource.com/uploads/short-url/8R8a2PRhAOeDvRhWSJ12p2jLU9y.zip) (18.8 KB)  
[coverage-client.xml.zip](https://community.sonarsource.com/uploads/short-url/11uRxSU1EPUQXRU5bF1jQTINvXn.zip) (5.9 KB)  
[coverage-server.xml.zip](https://community.sonarsource.com/uploads/short-url/i1vXWpe06zbexnU0IfVPr19PrJv.zip) (14.8 KB)

Again, here is the log for the action which should eb visible as it s a public repository:

> <https://github.com/baobabsoluciones/cornflow/actions/runs/14381231943/job/40676191388>

Right now I can not test it out on a local instance of SonarQube.

---

<div class="post-metadata">

**Author:** ![Guillaume\_Dequenne](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/guillaume_dequenne/32/7472_2.png) [@Guillaume\_Dequenne](https://community.sonarsource.com/u/Guillaume_Dequenne)\
**Post date:** [April 29, 2025, 7:54am UTC](https://community.sonarsource.com/t/error-parsing-python-coverage/138531/10 "2025-04-29T07:54:56Z")

</div>

Hello @ggsdc and sorry for coming back to this so late.

Since your project is public, I took the liberty to fork it and make a rough test on SonarQube Cloud, using the reports you provided.

As you can see [here](https://github.com/guillaume-dequenne/cornflow/actions/runs/14725961508/job/41328546995?pr=2#step:3:5185), the job ran as expected and coverage was imported properly. We can see that there are no failure in the logs, and the [PR analysis](https://sonarcloud.io/summary/new_code?id=guillaume-dequenne_cornflow&pullRequest=2) shows coverage information.

One notable element is that, when I initially used the coverage reports from the “develop” branch in the “master” branch, I did get a parsing failure due to a mismatch between the lines of code in the source and the ones referenced in the coverage report (see [here](https://github.com/guillaume-dequenne/cornflow/actions/runs/14725806959/job/41328076712#step:3:5183)).

Consequently, I believe there might be a mismatch in how your coverage report is being generated, possibly targeting outdated sources. The problem does not seem to come from SonarQube itself or from the Python analyzer.

Hope that helps,  
Guillaume

---

<div class="post-metadata">

**Author:** ![ggsdc](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ggsdc/32/68704_2.png) [@ggsdc](https://community.sonarsource.com/u/ggsdc)\
**Post date:** [July 2, 2025, 9:28am UTC](https://community.sonarsource.com/t/error-parsing-python-coverage/138531/12 "2025-07-02T09:28:38Z")

</div>

Hello Guillaume:

Sorry for the late response as I have been on leave for the past two months. If I understand this correctly, then the main issue is that there is a mitmatch between the coverage files and the actual source files?

Could this be because there is a lot of changes on source files between develop and master?

Would syncing these two branches help solve the issue?

---

<div class="post-metadata">

**Author:** ![Guillaume\_Dequenne](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/guillaume_dequenne/32/7472_2.png) [@Guillaume\_Dequenne](https://community.sonarsource.com/u/Guillaume_Dequenne)\
**Post date:** [July 4, 2025, 9:30am UTC](https://community.sonarsource.com/t/error-parsing-python-coverage/138531/13 "2025-07-04T09:30:46Z")

</div>

Hello @ggsdc,

Yes, this is the issue. The coverage computed for one branch is probably being used when analyzed another branch, which leads to mismatches, and eventual failure of the import.

Whether you sync the branches or not is ultimately a decision that depends on what you want to do with the project: you don’t need to do it to fix this problem. The main fix for SonarQube is to generate the report on the same branch that you’re analyzing and trying to import coverage information.

Cheers,  
Guillaume

---

<div class="post-metadata">

**Author:** ![ggsdc](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ggsdc/32/68704_2.png) [@ggsdc](https://community.sonarsource.com/u/ggsdc)\
**Post date:** [July 7, 2025, 9:17am UTC](https://community.sonarsource.com/t/error-parsing-python-coverage/138531/14 "2025-07-07T09:17:36Z")

</div>

> [@Guillaume\_Dequenne](#):
>
> Yes, this is the issue. The coverage computed for one branch is probably being used when analyzed another branch, which leads to mismatches, and eventual failure of the import.

But I do not understand that. Even if I point our SonarQube to the develop branch (again we are using SonarQube Community Edition, so we do not have PR analysis) I am not able to import the coverage run on the develop branch.

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/f/9/f9254a1f078e84a6744c7d04880159fe2fbb0020.png)

And the latest run:

> <https://github.com/baobabsoluciones/cornflow/actions/runs/15896428706>

and

> <https://github.com/baobabsoluciones/cornflow/actions/runs/15896428706/job/45221191058>

And from the logs:

```auto
14:36:24.065 INFO Python test coverage
14:36:24.067 INFO Parsing report '/home/runner/work/cornflow/cornflow/coverage-server.xml'
14:36:24.075 WARN Cannot read coverage report '/home/runner/work/cornflow/cornflow/coverage-server.xml', the following exception occurred: 'Error parsing the report '/home/runner/work/cornflow/cornflow/coverage-server.xml''
14:36:24.075 INFO Parsing report '/home/runner/work/cornflow/cornflow/coverage-client.xml'
14:36:24.075 WARN Cannot read coverage report '/home/runner/work/cornflow/cornflow/coverage-client.xml', the following exception occurred: 'Error parsing the report '/home/runner/work/cornflow/cornflow/coverage-client.xml''
14:36:24.075 INFO Parsing report '/home/runner/work/cornflow/cornflow/coverage-dags.xml'
14:36:24.075 WARN Cannot read coverage report '/home/runner/work/cornflow/cornflow/coverage-dags.xml', the following exception occurred: 'Error parsing the report '/home/runner/work/cornflow/cornflow/coverage-dags.xml''

```
