-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Describe the bug
When uploading distributions with twine I get the error HTTPError: 500 Server Error: Internal Server Error
when there is an unintentional trailing newline in the password. This is confusing as I would expect the error 403 Client Error: Invalid or non-existent authentication information.
or even an automatic stripping of whitepace.
This happens easily when using continuous deployment and authentication via github secrets, as it is easy to accidentally copy the token from the PyPI Add API token page with a trailing newline. This is then preserved when entering it into a textfield and thus included in the environment variable set by the runner.
As the server seems to be returning a confusing message I added this issue here instead of in the twine repo. Hope it's correct here.
Expected behavior
Receive authentication error or automatic stripping of whitespace
To Reproduce
Note the newline at the end of the token:
$ twine upload --repository-url https://test.pypi.org/legacy/ -u "__token__" -p "pypi-XXX
" dist/*
Uploading distributions to https://test.pypi.org/legacy/
Uploading somepackage-0.1-py3-none-any.whl
100%|██████████████████████████████████████████| 9.74k/9.74k [00:00<00:00, 12.0kB/s]
Received "500: Internal Server Error" Package upload appears to have failed. Retry 1 of 5
[...]
Received "500: Internal Server Error" Package upload appears to have failed. Retry 5 of 5
NOTE: Try --verbose to see response content.
HTTPError: 500 Server Error: Internal Server Error for url: https://test.pypi.org/legacy/
Without the newline at the end of the token the behavior is better:
$ twine upload --repository-url https://test.pypi.org/legacy/ -u "__token__" -p "pypi-XXX" dist/*
Uploading distributions to https://test.pypi.org/legacy/
Uploading somepackage-0.1-py3-none-any.whl
100%|██████████████████████████████████████████| 9.74k/9.74k [00:00<00:00, 10.4kB/s]
NOTE: Try --verbose to see response content.
HTTPError: 403 Client Error: Invalid or non-existent authentication information. for url: https://test.pypi.org/legacy/
My Platform
$ python --version
Python 3.6.9
$ twine --version
twine version 3.1.1 (pkginfo: 1.5.0.1, requests: 2.22.0, setuptools: 45.1.0,
requests-toolbelt: 0.9.1, tqdm: 4.41.1)