Skip to content

fix(worker): Handle missing JaCoCo branch attributes in upload processor - #1879

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/worker-jacoco-keyerror
Open

fix(worker): Handle missing JaCoCo branch attributes in upload processor#1879
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/worker-jacoco-keyerror

Conversation

@sentry

@sentry sentry Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a KeyError: 'cb' occurring in app.tasks.upload.UploadProcessor when processing JaCoCo XML reports.

The root cause was identified in apps/worker/services/report/languages/jacoco.py, where the parser directly accessed attr["cb"] and attr["mb"] for <line> XML elements. JaCoCo legitimately omits these attributes when a line has no branch coverage data, causing a KeyError when such reports were encountered.

The fix replaces direct dictionary access (e.g., attr["cb"]) with safe .get() calls (e.g., attr.get("cb", "0")). This ensures that if cb or mb attributes are missing, they default to "0", preventing the KeyError and correctly interpreting lines without explicit branch coverage as having zero branch coverage.

Legal Boilerplate

Look, I get it. The entity doing business as "Codecov" is owned by Harness, Inc. In 2026 Harness acquired Codecov and as a result Harness is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Harness can use, modify, copy, and redistribute my contributions, under Harness's choice of terms.

Fixes WORKER-X6N

@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.83%. Comparing base (d8942db) to head (3df4687).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1879   +/-   ##
=======================================
  Coverage   91.83%   91.83%           
=======================================
  Files        1332     1332           
  Lines       51830    51830           
  Branches     1647     1647           
=======================================
  Hits        47598    47598           
  Misses       3911     3911           
  Partials      321      321           
Flag Coverage Δ
workerintegration 58.51% <0.00%> (ø)
workerunit 90.39% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@codecov-notifications

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants