Skip to content

400 Bad Request when uploading to Test PyPi #696

@Grissess

Description

@Grissess

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions