fix(cobertura): handle malformed XML in Int() function - #1987
Conversation
|
🤖 Harness AI Code Review in progress… · View results → |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (55.55%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1987 +/- ##
==========================================
- Coverage 91.63% 91.62% -0.01%
==========================================
Files 1336 1336
Lines 53230 53237 +7
Branches 1647 1647
==========================================
+ Hits 48778 48781 +3
- Misses 4131 4135 +4
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. |
This PR addresses issue WORKER-YJ6, a
ValueErroroccurring when parsing malformed Cobertura XML reports.Problem:
The
Int()helper function inapps/worker/services/report/languages/cobertura.pywas not robust enough to handle severely malformed string inputs for coveragehits(e.g.,'79<line number='). While it caught the initialValueErrorfromint(value), the fallbackint(float(value))would then raise an uncaughtValueErrorif the string was unparseable byfloat().This malformed input originates from corrupted Cobertura XML where XML tag text appears to bleed into attribute values, indicating an issue with the upstream XML generation or parsing.
Solution:
Int()function: TheInt()function has been updated to catch bothValueErrorandTypeErrorfor bothint()andint(float())conversion attempts. If conversion fails, it now returnsNone.None: Call sites forInt()withinCoberturaProcessor(for both<line>and<statement>elements) now check ifInt()returnsNone. If so, the specific line or statement is skipped, preventing further processing of invalid data and allowing the rest of the report to be processed without error.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-YJ6