-
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
Index URLs containing unescaped "@" in username cause "Failed to parse" error in pip 19.2 #6775
Comments
+1 |
We also have issue with pip-19.2 when using specific index url :
It's working fine with pip-19.1.1. Could it be related ? |
@bomri, can you please re-run with |
Might be related to: |
We had the same problem with a special character in our password. |
Hi folks! Thanks for filing this issue and chiming in here. It'd be best that if you're facing this issue, that you use GitHub's reactions on the first post and subscribe to this issue. That way we can avoid "me too" comments which don't really add much value to the discussion. It'll make it easier for the maintainers to discuss how to go about resolving this issue, in this issue itself and provide updates to y'all more easily. 🙃 |
@chrahunt running with --verbose I get 404 on the pypi.org as expected (since the package doesn't exists there) but from my own pypi server I get:
maybe it is related to special characters in the token id like @brainerazer mentioned |
This has bitten us too. Not sure if this issue is related to the ones @brainerazer linked for I've created an empty private repo, with an empty release to test that. The output for
The issue/difference can be observed around |
Maybe @cjerdonek knows more about this stuff than me. |
I've also run a |
My thoughts: the current behavior is more technically correct and people should start using the new keyring support for this stuff. At the same time, it definitely isn't nice that this broke existing reasonable workflows. I think if someone can figure out how to re-introduce the legacy behavior here, that'd be great. Based on pip's documented deprecation policy, we don't need to have a deprecation cycle for such undocumented behaviors. None the less, we should do a deprecation cycle, warning users to switch to the more "correct" syntax or tooling here before dropping support and switching to a nicer error message. I'm not sure that the bisection found the right commit here but none the less, thanks for doing that! |
@pradyunsg, maybe I misunderstand.. can you please direct me to the needed "current behavior"? |
you're totally right. I corrected my test script and now it points to c63ee61 which makes more sense now I guess |
This comment has been minimized.
This comment has been minimized.
Whoops. Yes. (This is why I needed a nap) The issue here is that the parts of a URL should be... urlencoded. Thus, the
The correct way to represent this information would be:
If someone has an issue with that... They should probably take that up with the folks who wrote that RFC. It's mentioned in the urllib issue linked further up in this thread. Aside: @markuszoeller had pointed out the workaround in a different issue that's been closed as a duplicate of this. What I think I'm suggesting in that comment... is that pip could detect when the user does use such invalid URLs (since it accepted that in the past), warn the user, and work like 19.1.1 -- after some time, the warning and workaround would be removed. If y'all do think that's necessary after this breakage, do let us know. I'll be more than happy to just skip the additional work if it's not helpful to the folks affected by it -- there's no point in doing things that are not useful for the end users. 🙃 |
Indeed. I can see there why we weren't catching these uses earlier -- pip was doing "home grown" processing of the index URL's auth information which obviously didn't consider such input invalid. What changed is we're now using a urllib utility function to get parts of the URL, which is stricter and RFC compliant. |
right, now I get it, thanks @pradyunsg. For those watching at home ;) as a fix one can pass EDIT: |
No clue. I'm not a subject matter expert. All that I've said above is basically a well informed guess that I've made by looking at all the relevant bits of code on my phone... because my laptop is too far away from the bed. 🙃 |
Noting the last thing that I'm going to say here based on (only) intuition + memory, this seems like pip incorrectly requiring both username / password components to be present. If that's the case, it's almost certainly a bug, albeit a separate one. |
I tried @slafs last comment and it seems to be working fine for me. |
Following #6775 (comment), I've opened #6796 for the "one element" auth in the package URL. |
Thanks @slafs. In that case I think we can close this one. |
How about documenting this case in the docs (including with an example) since it seems common and can trip people up? |
@cjerdonek, added #6797 to track that action. |
I'd appreciate if folks from this thread could take #6818 for a spin and let me know if it works. To install pip from that branch, into your local environment, run:
|
I don’t think that PR fixes this issue? I thought this issue was about usernames that include an @ when a password is present (it doesn’t have to do with None / non-None), and the other issue is about no password being present. But I don’t see the former among the test cases. (There would need to be two unescaped @ symbols in the test cases.) Also, I thought fixing the former would mean we’d have to “fix” / rewrite the URL, which I don’t see being done in the PR. |
Ah, yes. My bad, I omitted the test for it. I've gone ahead and added that case to the test suite -- running it locally confirms that it extracted the email address correctly. "http://[email protected]:[email protected]/path" -> ("http://example.com/path", "[email protected]", "password")
Ah, yes. Me too initially. However, I looked at the diff of requests and urllib3 vendors and didn't see anything in a code path that affected us directly here. I decided to try seeing if reverting to the changes from the original structure worked and it seems like it did. My understanding now, is that it's got something to do with requests' default handling of URLs that contain auth information and (somehow) we're circumventing those issues in our |
No, if you look at my comment above where I included the traceback for this issue, you'll see that we pass the original URL: #6775 (comment) Just to be sure, I retried that command in your PR and confirmed that the same error still happens. |
Here is my comment above where I talk about one approach to fixing the current issue: #6775 (comment) |
Right, makes sense to me. I think I was mixing issues in my head. |
It would also make sense to abort in this situation, and print a warning if there's an unescaped "@" in the URL. It's probably more discoverable than the documentation and is friendlier than having it in the documentation. Summarizing the state of affairs in pip 19.2, for my stupid self:
|
Hi, we are facing the same issue with pip 18.1, urllib3(1.24.1) & Python2.7 but in the password section. |
Released pip 19.2.2 containing a fix for the tokens needing a For folks facing issues with |
Edit: Doesn't seem to be related to the '%', as I changed my password to "password" and got the same result. Another kink in this: my old generated password (used to) end in "%". On version 19.2.2 Replacing the (Assuming my password was:
or
|
Can you try encoding only the credential portion of the URL - e.g. |
Switching to |
There's nothing more actionable here. As a closing note, I'll summarize this issue and make a call-to-action. What happened? pip 19.2 now requires credentials to be URL quoted. Thus, characters like Thus, the following index-urls will no longer work:
The equivalents that do work, are:
Why? pip (and requests) use urllib3 for a lot of the underlying URL handling. urllib3 has introduced stricter URL parsing in the version that pip upgraded to in 19.2. Since this strictness was only "caught" after the release, pip's developers decided to not to circumvent the stricter parsing. The workflows for affected users had already broken and none pointed out that it'd be particularly difficult for them to quote their credentials properly. How can you help? pip's developers do not want to be breaking their users' workflows. However, this is difficult since pip is a project maintained entirely by volunteers, with a legacy codebase that makes on-boarding additional contributors difficult. There is a substantial lack of developer time on pip, especially given the impact that changes in it, can have on users. To help us avoid issues like this and make more substantial improvements to pip, consider funding Python Packaging improvements. Funding such projects related to pip, would allow current maintainers be able to work on pip for more time, and bring in additional experts (UX experts, project managers, technical writers etc) to make pip better. |
Environment
Description
After updating to pip-19.2 from pip-19.1.1 installing packages with --extra-index-url doesn't work and I get:
going back to 19.1.1 works fine
The text was updated successfully, but these errors were encountered: