Skip to content

fix(worker): Handle missing JaCoCo branch attributes in XML parsing - #1673

Closed
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/jacoco-missing-attrs
Closed

fix(worker): Handle missing JaCoCo branch attributes in XML parsing#1673
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/jacoco-missing-attrs

Conversation

@sentry

@sentry sentry Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

This PR addresses KeyError: 'mb' and similar errors occurring in the JaCoCo XML parser (apps/worker/services/report/languages/jacoco.py).

Problem: The parser was using direct dictionary access (attr['mb'], attr['cb'], attr['ci'], attr['nr']) to retrieve attributes from JaCoCo <line> elements. Some non-standard JaCoCo reports, particularly from an enterprise uploader, omit these branch-related attributes when a line has no branch coverage data. This led to KeyError exceptions, causing report processing to fail.

Solution: The code has been updated to use attr.get() with default values (e.g., attr.get('mb', '0'), attr.get('cb', '0'), attr.get('ci', '0')). Additionally, a guard has been added for the nr (line number) attribute to ensure int() conversion doesn't fail if it's missing, skipping the line if nr is not present.

Impact: This change prevents crashes when processing JaCoCo reports that omit optional branch attributes, ensuring robust parsing for both standard and non-standard JaCoCo outputs. There is no change in behavior for well-formed JaCoCo reports.

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-VYP

@codecov-notifications

codecov-notifications Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
apps/worker/services/report/languages/jacoco.py 91.66% 1 Missing ⚠️

📢 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.

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.85%. Comparing base (7fd98bf) to head (7493474).
⚠️ Report is 7 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
apps/worker/services/report/languages/jacoco.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1673      +/-   ##
==========================================
- Coverage   91.85%   91.85%   -0.01%     
==========================================
  Files        1329     1329              
  Lines       51550    51556       +6     
  Branches     1647     1647              
==========================================
+ Hits        47352    47357       +5     
- Misses       3877     3878       +1     
  Partials      321      321              
Flag Coverage Δ
workerintegration 58.59% <0.00%> (-0.03%) ⬇️
workerunit 90.40% <91.66%> (-0.01%) ⬇️

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.

@thomasrockhu-codecov

Copy link
Copy Markdown
Contributor

Closing as duplicate Seer effort.

Reason: duplicate missing JaCoCo branch-attributes fix; consolidated into #1879.

Part of a triage pass consolidating overlapping sentry[bot] PRs so review capacity focuses on unique fixes.

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.

1 participant