-
Notifications
You must be signed in to change notification settings - Fork 311
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
leaving out a trailing slash in the pypi URL causes twine to fail with a 410 #310
Comments
So the unfun bit is that we get a 410 but 410 is pretty generic. If Warehouse returned a JSON body, we could perhaps introspect that and retry with a trailing slash. We could also parse the URL, detect |
And the 410 is from Warehouse, so making it a 301 or a 302 is a feature request for Warehouse. 😄 |
I don't think redirects work reliably because the API is a |
Twine doesn't automagically follow redirects on POSTs for many reasons, not the least of which is that we're using file-like objects whose positions don't auto-reset. We could follow them manually easily if we wanted to. I think, however, that the better user experience is to special case this with PyPI and handle it in the |
Had I not found this issue I would not have been able to upload. No trailing '/' in
Resulting error:
No idea what that means... Did a bit of googling.. got lucky that this thread showed up as a match for "RedirectDetected". Notice a mention of trailing '/'.. No other search results come close to relating to this issue. Added trailing '/' in
Works. I would really like to see the error handling improved. Side question: If I'm using pip and virtualenv. Package deployment seems to need a setup.py though. Why can't i use my Pipfile instead? |
@patrick-motard thanks for the feedback. As for your side question, that would be better brought up on https://github.com/pypa/packaging-problems (if it hasn't been discussed there already). |
If anyone else runs into the same issue, I also neglected a trailing slash and got a 404 on our devpi instance (anonymized to protect the innocent):
Adding the trailing slash fixed things. Thanks for making this issue! |
Thanks, @bhrutledge! |
We got a request for this at a recent sprint night from a new contributor. @bhrutledge what do you think? |
@brainwane Seems reasonable, and per my comment in #460:
That said, I'm slightly wary of implicitly altering the configured repositories, and continuing down the path of special-casing. In light of #499 & #509, I'm wondering if a "better" approach would be to sanity check the repository URL prior to upload, and abort with a helpful error message. Something like: if "pypi.org" in url and url not in [DEFAULT_REPOSITORY, TEST_REPOSITORY]:
print(
f"The configured repository {url} is not a known PyPI repository.\n"
f"Did you mean {DEFAULT_REPOSITORY} or {TEST_REPOSITORY}?\n"
f"See {PYPIRC_DOCS} for details."
)
return This would put up a temporary roadblock, but would encourage folks to have a "correct" configuration. If that sounds like a good idea, I'm inclined to open that as a new Maybe the @pypa/twine-maintainers have opinions? |
|
SGTM |
Adding trailing |
@bhrutledge Do you think this will work? We could provide this message: f"The configured repository {url} is not a known PyPI repository.\n"
f"Did you mean {DEFAULT_REPOSITORY} or {TEST_REPOSITORY}?\n" Then, we could ask users whether they want to update the configured repository in the
If users input yes, we will add trailing Therefore, users will know that twine has modified their |
I would think this is helpful but I would also give people the ability to specify the config file to save it to. Some people might want to diff the two files to ensure it's only changed the URL. I would also remove |
@meowmeowmeowcat @sigmavirus24 I appreciate the suggestions to help the user, but this also feels like a complex bit of behavior to implement, test, and review. For example, thus far, Twine does not write to the configuration file. It also seems like this issue doesn't come up very often. With all that in mind, I would rather start with the lighter-weight "help" message proposed in #310 (comment), maybe extending it to mention the configuration file, or suggesting |
Generally the consensus around developer tooling these days is "If you know how to fix this and can fix it for me, why don't you?" This should be very little effort and complexity.
I would suggest expanding the very basic message to print a "diff" to help make it clearer what the difference is. Not everyone might understand the phrasing we pick in english, but most should be able to look at a diff and understand what the change necessary is. |
Probably this could be closed as solved? We have provided an improved redirect message with #812. |
@meowmeowmeowcat I haven't closed it because there was some follow up that I wanted to do:
|
After taking a closer look, I'm going to close this with no further changes. Unlike the redirect case, a 404 on a URL without a trailing slash doesn't necessarily imply that adding a trailing slash is the proper resolution; for example, it could mean a typo in the URL. |
Given a
[test]
repository described ashttps://test.pypi.org/legacy
in a.pypirc
file,twine upload --repository test dist/*
fails withHTTPError: 410 Client Error: This API has moved to https://test.pypi.org/legacy/. See TODO for more information. for url: https://test.pypi.org/pypi
.Repro case with
.pypirc
: https://gist.github.com/markrwilliams/01a235daeee2d6a0068a22d2faa7b2cbCould we in this case fix the trailing slash to make life easier for users?
The text was updated successfully, but these errors were encountered: