-
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
Restrict #egg=
fragments to valid PEP 508 names
#11617
Restrict #egg=
fragments to valid PEP 508 names
#11617
Conversation
This should help reduce user confusion about what can go in a URI's egg fragment. Fixes pypa#11567. Signed-off-by: William Woodruff <william@trailofbits.com>
Should have run tests locally first 😅 Looks like there are a couple of unit tests that assert that |
Test failures need further investigation.
IMO this does need a news fragment, as it's a behaviour change.
Lol, I approved too fast, as well 🙂 Given that the documentation says that only a project name is allowed, here, I'm not sure what those tests are doing. I don't think we shoud just adjust the check to match the tests, I think we should establish properly what is a valid Sorry, I appreciate that's more work than you'd originally expected... |
Sounds good! I'll add one once we work out exactly what's changing here 🙂
Makes sense to me. Thinking about it more, it makes (some) sense to me that the
to install package
...or worse, those lines and this one:
( |
This should now be consistent with existing tests (without establishing that those tests are actually well-specified). Signed-off-by: William Woodruff <william@trailofbits.com>
It looks like support for extras in egg fragments has been around for a long time, since at least 2012: #7 Edit: and another example of someone intentionally using extras in the egg fragment, and |
Based on the above, I think the right approach here is:
Does this seem reasonable to you @pfmoore? If so, I can do it in this same PR (or break the docs out into a separate one; whatever's easier). |
OK. I'm still not clear what If that's the interpretation, then the extra seems to me to not be part of the Whatever the answer, I think the docs need to be clear on what is going on here, so we need some documentation change. The simplest change would be to just say that the I don't think I've mentioned it for a while, but I really, really hate extras 🙁 |
lol, yet again we're both typing at the same time 🙂 I'm not quite sure what you mean in item (3), but you clearly understand what you want to achieve there, so that's fine. And I think your overall approach is correct, yes. |
That's my understanding of it, at least 😅 -- I agree that the extra doesn't actually make sense in that position, but it looks like the rest of the requirements handling code assumes that it can be there and respects it (probably for expediency, like you said).
Sorry for the confusion. What I mean is that this currently (even with my changes) doesn't produce an error:
...since the egg fragment is never actually evaluated in the presence of the |
This doesn't actually address the semantics of extras in the egg fragment. Signed-off-by: William Woodruff <william@trailofbits.com>
This should prevent us from accepting malformed egg fragments that are shadowed by other parts of the requirement specifier. Signed-off-by: William Woodruff <william@trailofbits.com>
This exercises our expectation that egg fragments don't include version specifiers and are evaluated eagerly. Signed-off-by: William Woodruff <william@trailofbits.com>
Okay, all of the behavioral changes should be there. If this looks reasonable I'll do the |
Here's an alternative suggestion: Let's warn when we detect a non-identifier It doesn't "solve" the issue "immediately", but it does present the warning to users for a 6 month period allowing them to adapt per our deprecation policy. And, we'll have a fuller fix on the other side of that deprecation period. (yes, this means also erroring out on |
That sounds pretty good to me -- IIUC, nobody should ever need to use extras in an egg fragment: In that case, I can rewrite this PR to spit out a warning instead, but leave the docs tweaked (maybe with an additional warning that the behavior is changing). |
Turkey time is over, so I'll resume on this this week... |
I've been thinking about this a little bit more, and...maybe it makes sense to deprecate I can still leave this PR to just the subject of restricting egg fragments to PEP 508 names, but IMO that's another long-term option worth thinking about. |
Signed-off-by: William Woodruff <william@trailofbits.com>
This turns invalid egg fragments into a soft error, with a scheduled deprecation period of two releases. Signed-off-by: William Woodruff <william@trailofbits.com>
Rewrote this into a deprecation instead. I've kept the unit test around and made it into an |
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
CI failures look unrelated:
|
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.
Sounds good to me. Can you rebase to see if we get a green CI?
Related: in #11676 I update the docs to clarify that the egg fragment is only necessary for editable VCS URLs.
Merged; let me know if you're prefer a full rebase instead 🙂 |
I updated the description here, since users are ending up on this page from the link in the error message added in this PR. :) |
For users landing here from the error message: The
egg
fragment should be a bare PEP 508 project name. Anything else is not guaranteed to work and that is what the error is telling you.If you have something like:
You can change it to something like:
Or, even completely drop the
#egg
fragment in many situations.This should help reduce user confusion about what can go in a URI's egg fragment.
I haven't added aNEWS
entry yet since this is a small correctness change, but if it meets the notability bar I'm happy to add one!Fixes #11567.
Signed-off-by: William Woodruff william@trailofbits.com