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

400 Bad Request when uploading to Test PyPi #696

Open
Grissess opened this issue Oct 23, 2024 · 2 comments
Open

400 Bad Request when uploading to Test PyPi #696

Grissess opened this issue Oct 23, 2024 · 2 comments

Comments

@Grissess
Copy link

Grissess commented Oct 23, 2024

Hello! I'm not sure if this is on you or on Test PyPI, but I was having trouble publishing (experimentally) a local build thereto:

$ flit publish --repository testpypi
...
Traceback (most recent call last):
  File "/usr/host/bin/flit", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/x86_64-pc-linux-gnu/lib/python3.12/site-packages/flit/__init__.py", line 200, in main
    main(args.ini_file, repository, args.pypirc, formats=set(args.format or []),
  File "/usr/x86_64-pc-linux-gnu/lib/python3.12/site-packages/flit/upload.py", line 277, in main
    do_upload(built.wheel.file, built.wheel.builder.metadata, pypirc_path, repo_name)
  File "/usr/x86_64-pc-linux-gnu/lib/python3.12/site-packages/flit/upload.py", line 252, in do_upload
    upload_file(file, metadata, repo)
  File "/usr/x86_64-pc-linux-gnu/lib/python3.12/site-packages/flit/upload.py", line 245, in upload_file
    resp.raise_for_status()
  File "/usr/x86_64-pc-linux-gnu/lib/python3.12/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://test.pypi.org/legacy/

I checked around a few times to be confident that this ~/.pypirc seemed valid:

[distutils]
index-servers =
  pypi
  testpypi

[pypi]
repository = https://upload.pypi.org/legacy/
username = __token__

[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__

(I'm inserting the tokens out of band :)

After a few times of suspecting it was an auth error or some other shenanigan, it (to my surprise) succeeded when I uploaded with flit publish to main PyPI. Of course, I'd rather have tested that the release went alright (even though it seems to have), so this isn't an ideal situation.

EDIT: To be sure, this seems very rare--no Internet search I consulted had the exact string Bad Request for url: https://test.pypi.org/legacy/ return any results. It certainly doesn't seem to be a dupe of #455!

@takluyver
Copy link
Member

Hmm, that's interesting. Is it possible the package you were trying to upload was already there on TestPyPI, and it was refusing to accept the same package twice? I'd hope it would give a clearer error message for that, but it's possible. I don't think Flit should do anything different for Test PyPI & regular PyPI, other than the different URL.

@Grissess
Copy link
Author

I didn't actually change any details before it uploaded (successfully!) to main PyPI--that's not to say it couldn't have already been on TestPyPI, although, if memory serves, I failed to upload it due to authentication issues the first couple tries :)

You're right, if that was the issue, I'd hope the error message would have been better. I could nonetheless try to repro, for what it's worth...

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

No branches or pull requests

2 participants