Upload to PyPI silently fail
See original GitHub issue-
I am on the latest Poetry version.
-
I have searched the issues of this repo and believe that this is not a duplicate.
-
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option). -
OS version and name: MacOS Mojave
-
Poetry version: 0.12.10
Issue
poetry publish
fails silently if the Pypi server returns an error:
- If I use invalid credentials (it even shows the “Uploading foobar.tar.gz 100%” mesage)
- If the Pypi server returns an error.
I was trying to upload a project with an invalid name (“pipes”, invalid because Python standard library has a module named the same) and nothing indicated me that the publishing was failing.
If I try with twine this is the output instead:
$ twine upload dist/*
Uploading distributions to https://upload.pypi.org/legacy/
Uploading Pipes-0.1.0-py3-none-any.whl
100%|████████████████████| 4.26k/4.26k [00:00<00:00, 7.88kB/s]
NOTE: Try --verbose to see response content.
HTTPError: 403 Client Error: The user 'jpscaletti' isn't allowed to upload to
project 'pipes'. See https://pypi.org/help/#project-name for more information.
for url: https://upload.pypi.org/legacy/
I think #742 is a specific case of this issue.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Can't upload package to PyPi - Stack Overflow
I've been trying to upload a package to PyPi. I receive this error every time. Upload failed (403): Invalid or non-existent authentication ...
Read more >twine upload - Read the Docs
More documentation on using Twine to upload packages to PyPI is in the Python Packaging ... --help show this help message and exit...
Read more >Changelog - pip documentation v22.3.1
Create the cache directory when the pip version check needs to save to it instead of silently logging an error. Fix a regression...
Read more >Merge "Retry twine uploads in a loop" · 3bfe80d94a - project-config ...
twine upload -r pypi $FILENAME || true. curl --head --silent --fail "https://pypi.python.org/simple/$PROJECT/$FILENAME" >/dev/null 2>&1.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@sdispater I have a fairly good idea why this is happening and a proposal for a fix.
In uploader.py
The bug is triggered when the URL is not exactly
https://test.pypi.org/legacy/
(note the trailing/
). If the URL is missing the trailing/
, the response will be a 301 redirect to/legacy/
.resp.ok
is stillTrue
in this case, but the upload did not take place (nor was the redirect followed). Settingallow_redirects=True
does make requests follow the redirect, but it doesn’t seem to perform the upload (BUT the status code becomes 200). The same thing happens for/simple
(gets redirected to/simple/
). If the URL is configured to/simple/
, a HTTP 405 error is raised.In summary:
/legacy
-> silently fails because of 301 status,resp.ok
is True/legacy/
-> works ✨/simple
-> silently fails because of 301 status,resp.ok
is True/simple/
-> fails with 405 statusMy proposal for the fix is:
resp.status_code == 200
instead ofresp.ok
This will make
/simple
fail as 405, too, and/legacy
will work. I think it would be worthwhile to highlight in the docs that the legacy API is expected by poetry.Also, it might be a good idea to add a default
testpypi
repository to the configuration?If this proposal is liked, I’m happy to implement the first two points and open a PR. Point 3 is an improvement.
I just wanted to add it seems my private repo seemed to have 405 problems with either legacy or simple. I corrected by chopping both off.
final url:
http://myserver.com
(note the lack of “legacy” or “simple”
Comment that pointed me in that direction: https://github.com/pypiserver/pypiserver/issues/212#issuecomment-454661922