Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: a couple uncaught exceptions during coverage processing #908

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

matt-codecov
Copy link
Contributor

@matt-codecov matt-codecov commented Nov 20, 2024

related to codecov/engineering-team#1520

i reviewed all of the uncaught exceptions during report processing. this PR addresses two of the highest-firing ones. others should be addressed but are more work and don't fire as frequently so i am punting on them

the services/report/report_processor.py change addresses a somewhat common uncaught exception: ValueError: invalid literal for int() with base 10: 'ignored'. JSON-ified simplecov reports have "ignored" as a coverage value for skipped lines. we should convert those to -1 which is how the pyreport format represents skipped lines

the services/report/languages/simplecov.py change addresses the dominant uncaught exception during report processing: lxml.etree.XMLSyntaxError: Document is empty, line 1, column 1. the surrounding code is basically blindly attempting to parse it as JSON, and then attempting to parse it as XML, and then returning "it's a text file" if neither passes. so failing to parse it as XML is fine, we just weren't catching all the relevant exceptions. now we are. if these are truly empty files, i think they will no-op and if the overall upload has no non-empty files then we will return a ReportEmptyError and set the appropriate error code.

@matt-codecov matt-codecov requested a review from a team November 20, 2024 23:15
Copy link

codecov bot commented Nov 20, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 97.99%. Comparing base (ab219bc) to head (90fa2ee).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
services/report/languages/simplecov.py 50.00% 1 Missing ⚠️
services/report/report_processor.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #908      +/-   ##
==========================================
- Coverage   97.99%   97.99%   -0.01%     
==========================================
  Files         446      446              
  Lines       35634    35636       +2     
==========================================
+ Hits        34920    34921       +1     
- Misses        714      715       +1     
Flag Coverage Δ
integration 41.98% <0.00%> (-0.01%) ⬇️
unit 90.84% <33.33%> (-0.01%) ⬇️

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

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

@codecov-notifications
Copy link

codecov-notifications bot commented Nov 20, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
services/report/languages/simplecov.py 50.00% 1 Missing ⚠️
services/report/report_processor.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link

✅ All tests successful. No failed tests were found.

📣 Thoughts on this report? Let Codecov know! | Powered by Codecov

Copy link
Contributor

@Swatinem Swatinem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the eager json/xml parsing, we should maybe check that the contents start/end with {} or [] in case of json, or <> in case of xml.

I contemplated adding such a check before attempting a real parse, just to notice that we have a test that begins with a BOM which you can’t easily strip.

Maybe stripping trailing whitespace and then just checking that the file ends with ]} for json or > for xml would also work. Might be worth thinking about as a followup.

@matt-codecov matt-codecov added this pull request to the merge queue Nov 21, 2024
Merged via the queue into main with commit ff51806 Nov 21, 2024
14 of 27 checks passed
@matt-codecov matt-codecov deleted the pr908 branch November 21, 2024 16:09
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.

2 participants