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

twine should not fail silently #92

Closed
sashkab opened this issue Jan 30, 2015 · 14 comments · Fixed by #94
Closed

twine should not fail silently #92

sashkab opened this issue Jan 30, 2015 · 14 comments · Fixed by #94

Comments

@sashkab
Copy link

sashkab commented Jan 30, 2015

I've tried uploading package to pypi and it failed silently.

Twine reported, that file was uploaded, but actually file wasn't shown anywhere on pypi.

@dstufft
Copy link
Member

dstufft commented Jan 30, 2015

What file?

@sashkab
Copy link
Author

sashkab commented Jan 30, 2015

In this case it was wheel.

@dstufft
Copy link
Member

dstufft commented Jan 30, 2015

No I mean what project, version, filename on PyPI.

@sashkab
Copy link
Author

sashkab commented Jan 30, 2015

pygments-q, 0.5, pygments_q-0.5-py2.py3-none-any.whl.

Note, that another owner was able to upload file without a problem.

@dstufft
Copy link
Member

dstufft commented Jan 30, 2015

I see that file on https://pypi.python.org/pypi/pygments-q. Did you perhaps just check too soon before the Web UI cache was updated with the new version?

@sashkab
Copy link
Author

sashkab commented Jan 30, 2015

It was uploaded from different project owner's account couple minutes later and it did show up there right away. For my username/password combination it silently failed. And I waited for 10-15 minutes for it to show up.

@dstufft
Copy link
Member

dstufft commented Jan 30, 2015

Hmm. Strange. That would mean that PyPI accepted it but didn't save it somehow.

@sashkab
Copy link
Author

sashkab commented Jan 30, 2015

Ok, I think I figured out what heppend:

  1. I had wrong URL for repository. Instead of https://pypi.python.org/pypi I had https://www.python.org/pypi.
  2. When you connect to https://www.python.org/pypi, you get 301 redirect to correct URL:
$ curl -I https://www.python.org/pypi
HTTP/1.1 301 Moved Permanently
Date: Fri, 30 Jan 2015 18:25:54 GMT
Server: nginx
Content-Type: text/html
Location: https://pypi.python.org/pypi?
...

Is this case supported?

@dstufft
Copy link
Member

dstufft commented Jan 30, 2015

Ah. No it's not supported.

I wonder if we should get rid of that redirect.

@sashkab
Copy link
Author

sashkab commented Jan 30, 2015

It's better to update Python documentation, which pointed me to wrong server ;-)

@sashkab
Copy link
Author

sashkab commented Jan 30, 2015

But still, if it is not supported, you should say so somehow in the error message.

sigmavirus24 added a commit that referenced this issue Jan 31, 2015
PyPI will never redirect a user during an upload. If a redirect is
found, either the index URL is incorrect or there could be a malicious
redirect at play. requests has well defined behaviour around handling
POSTing data and what happens during a redirect. We shouldn't have to
think too hard about that and there's probably a problem the user needs
to handle if there is a redirect.

Requests added 'is_redirect()' to Response objects in 2.3.0. In order to
rely on that, we need to bump our minimum version.

Closes #92
@sigmavirus24
Copy link
Member

So I toyed with raising an exception in the case of a redirect but I'm not exactly sure it's the best idea. It would be pretty simple so long as we bump the minimum version of requests. I don't think anyone is using twine for anything other than PyPI, so it should be a relatively reliable way of preventing this kind of confusion.

That said, a redirect to a different subdomain would cause requests to not attempt to post the body again, so the redirect like that won't ever be successful. I have pushed a branch with my rough approximation of what this would look like. https://github.com/pypa/twine/tree/bug/92

@sashkab
Copy link
Author

sashkab commented Jan 31, 2015

I like your change - that would have saved me an hour or so of my time today. :)

sigmavirus24 added a commit that referenced this issue Jan 31, 2015
PyPI will never redirect a user during an upload. If a redirect is
found, either the index URL is incorrect or there could be a malicious
redirect at play. requests has well defined behaviour around handling
POSTing data and what happens during a redirect. We shouldn't have to
think too hard about that and there's probably a problem the user needs
to handle if there is a redirect.

Requests added 'is_redirect()' to Response objects in 2.3.0. In order to
rely on that, we need to bump our minimum version.

Closes #92
@doismellburning
Copy link

I just experienced this issue, and @sigmavirus24's fix proposal looks better than everything I've come up with <3

sigmavirus24 added a commit to sigmavirus24/twine that referenced this issue Apr 16, 2015
PyPI will never redirect a user during an upload. If a redirect is
found, either the index URL is incorrect or there could be a malicious
redirect at play. requests has well defined behaviour around handling
POSTing data and what happens during a redirect. We shouldn't have to
think too hard about that and there's probably a problem the user needs
to handle if there is a redirect.

Requests added 'is_redirect()' to Response objects in 2.3.0. In order to
rely on that, we need to bump our minimum version.

Closes pypa#92
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 a pull request may close this issue.

4 participants