fix(worker): Handle missing JaCoCo branch attributes in XML parsing - #1673
fix(worker): Handle missing JaCoCo branch attributes in XML parsing#1673sentry[bot] wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
|
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. |
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 toKeyErrorexceptions, 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 thenr(line number) attribute to ensureint()conversion doesn't fail if it's missing, skipping the line ifnris 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