-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Catch + report BadZipFile
errors in get_wheel_distribution
#10535
Conversation
I don't know if this is necessary. The |
@DiddiLeija Can you elaborate on your remark? As explained, the message is completely unhelpful to me because I don't even know what file or wheel it is about. It might be useful to the expert who knows the precise internals of what (note also that the stacktrace is an excerpt; I have no reason to assume that the |
You're right, my misreading:
Thinking a bit about this, this could be a good aproach, but we may have to sketch how the message must look like. BTW, before going ahead, I recommend you to write a news entry, because this change is not trivial (I think). See https://pip.pypa.io/en/stable/development/contributing/#news-entries for more information. Also, you may have to write a test for this behavior. |
Instead of raising |
I think it's also likely better to handle this in |
#9964 is one example of what situations might cause this corruption. |
Small addition: The error occurred with With that in mind, note how my stracktrace is slightly different as it would be now. It goes
but now it would instead go
|
@DiddiLeija any pointers for which kind of test I should write? A unit test in I'm not too familiar with pip's test concept. |
I think a functional test would be better in this case. |
@uranusjr I followed your instructions. Also, I added a news file as suggested. A test is still missing. I'm not sure whether Note that in the case of HTTP transfer, i.e. a call of @DiddiLeija gotcha. |
Let's go with |
Following I see two options:
Writing a unit test for this behavior proved a lot simpler, so it sounds reasonable to me to go for option 2 and leave the unit test in, so we can test both the general behavior (“some stacktrace”) and the specific handling ( |
I think option 2 makes more sense as well. |
Done, and in addition
|
Sorry for all the force-pushes, I know it requires reapproval. I forgot to squash some stuff, I'm finished now. |
Note that the functional test does not actually detect the behavioral change of throwing unhandled `BadZipFile` → throwing unhandled `InvalidWheel`, whereas the unit test does.
pre-commit does not like trailing spaces. |
Ah, I forgot to |
Just checking in, is any further work required from my side? |
Porbably not (at least not from me). I'll leave this open in case someone wants to take a look, but also add this to 22.0 so it can be merged if no-one has any objections. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my side, this PR is ready. Thanks @lukasjuhrich!
Co-authored-by: Pradyun Gedam <[email protected]>
Thanks a lot for this @lukasjuhrich! ^>^ |
Change
Catch
BadZipFile
errors and re-raise with some context information.No functional change, hence no news entry.
Motivation
I'm facing a few nasty CI bugs where the
pip install
command fails with an uncaughtBadZipFile
exception. A stacktrace looks like this:Since the information which file caused the error is missing, I don't have any means to further narrow down this issue (e.g. check which files are affected, compare checksums, etc). This change should help me and anyone else facing such issues.
NB
Please note that I have no clue about PIP internals; feel free to make any changes if e.g. the error message is factually incorrect.