gh-action-pypi-publish: HTTPError: 400 Bad Request from https://test.pypi.org/legacy/ (with no additional information)

Hello team!

I’ve implemented this action into my workflow here, but for nearly every build (I’m unsure of why it sometimes passes) I am getting a failure on this job (e.g. this instance) with only the following showing in the logs:

Transparency log entry created with index: 148295038
Uploading distributions to https://test.pypi.org/legacy/
Uploading rat_king_parser-3.1.5-py3-none-any.whl
WARNING  Error during upload. Retry with the --verbose option for more details. 
ERROR    HTTPError: 400 Bad Request from https://test.pypi.org/legacy/          
         Bad Request                                                            

I’m unsure of how to increase the verbosity via Actions to learn more about the request, and strangely, the package still ends up deployed on test.pypi.org even with the failure. But the pipeline on GitHub shows it as a failure all the same.

I was wondering if you all had any insight into what can cause this issue - Please let me know if I can provide additional logging in order to help triage.

Thank you for your hard work!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (6 by maintainers)

Commits related to this issue

Most upvoted comments

@webknjaz Might be nice to include the full error message at the lowest level of verbosity to avoid situations like this in the future.

Thank you for the great conversation here!

For my part, I was able to resolve this issue, and it turned out to be a user error: I had not restricted my publishing actions to the master branch, so every time a new tag was pushed to the repo, the workflow was triggered twice - Once for the master branch, and once for the new tag.

Adding verbose: true to my workflow YAML did indeed help, as it alerted me to the true source of the 400 error code:

Uploading rat_king_parser-3.1.7-py3-none-any.whl
INFO     Response from https://test.pypi.org/legacy/:                           
         400 Bad Request                                                        
INFO     <html>                                                                 
          <head>                                                                
           <title>400 File already exists                                       

The package was being uploaded twice: Successful on the first push to master, unsuccessful on the push to the tag as the release already existed after the push to master.

All of that said, I appreciate the work done in the repos referenced above that seek to emit the root error of the 400 response so that even if verbose is not set, the user can see what the true cause of the issue is.

Unless you want to address any other Issues raised here, please feel free to close this Issue at your discretion.

Hi @jeFF0Falltrades,

I have the same problem, see this. How do you specify that you want to publish to master? I have this in my publishing section:

  publish-to-testpypi:
    name: Publish Python 🐍 distribution 📦 to TestPyPI
    needs:
    - build
    runs-on: ubuntu-latest

    environment:
      name: testpypi
      url: https://test.pypi.org/p/rx_selection

    permissions:
      id-token: write  # IMPORTANT: mandatory for trusted publishing

    steps:
    - name: Download all the dists
      uses: actions/download-artifact@v4
      with:
        name: python-package-distributions
        path: dist/
    - name: Publish distribution 📦 to TestPyPI
      uses: pypa/gh-action-pypi-publish@release/v1
      with:
        repository-url: https://test.pypi.org/legacy/

@di well, we can’t control individual messages Twine prints out. We call Twine via CLI since there’s no public API (https://github.com/pypa/twine/issues/194 / https://github.com/pypa/twine/pull/361).

We can only flip the default value of the verbose input but that would generate a lot of output confusing people…

Closing, since the mysteries reported above seem to have been solved by now…

Thank you for the great conversation here!

For my part, I was able to resolve this issue, and it turned out to be a user error: I had not restricted my publishing actions to the master branch, so every time a new tag was pushed to the repo, the workflow was triggered twice - Once for the master branch, and once for the new tag.

Adding verbose: true to my workflow YAML did indeed help, as it alerted me to the true source of the 400 error code:

Uploading rat_king_parser-3.1.7-py3-none-any.whl
INFO     Response from https://test.pypi.org/legacy/:                           
         400 Bad Request                                                        
INFO     <html>                                                                 
          <head>                                                                
           <title>400 File already exists                                       

The package was being uploaded twice: Successful on the first push to master, unsuccessful on the push to the tag as the release already existed after the push to master.

All of that said, I appreciate the work done in the repos referenced above that seek to emit the root error of the 400 response so that even if verbose is not set, the user can see what the true cause of the issue is.

Unless you want to address any other Issues raised here, please feel free to close this Issue at your discretion.