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

PyPI reStructuredText README description validation fails even though twine check --strict passes #16500

Closed
antonlydell opened this issue Aug 18, 2024 · 1 comment
Labels
bug 🐛 requires triaging maintainers need to do initial inspection of issue

Comments

@antonlydell
Copy link

Describe the bug

The PyPI reStructuredText README description validation fails even though the README passes the twine check --strict command. When I on 2024-08-17 tried to upload a new version of my package to PyPI I ran the command twine upload dist/* and the "dist" directory contains the new and all previous versions of my package. When twine processed a previous version of my package that previously successfully uploaded to PyPI I got the error message listed below.

Response from https://test.pypi.org/legacy/:                                                                                                                                         
         400 The description failed to render for 'text/x-rst'. See https://test.pypi.org/help/#description-content-type for more information.                                                
INFO     <html>                                                                                                                                                                               
          <head>                                                                                                                                                                              
           <title>400 The description failed to render for 'text/x-rst'. See https://test.pypi.org/help/#description-content-type for more information.</title>                               
          </head>                                                                                                                                                                             
          <body>                                                                                                                                                                              
           <h1>400 The description failed to render for 'text/x-rst'. See https://test.pypi.org/help/#description-content-type for more information.</h1>                                     
           The server could not comply with the request since it is either malformed or otherwise incorrect.<br/><br/>                                                                        
         The description failed to render for &#x27;text/x-rst&#x27;. See https://test.pypi.org/help/#description-content-type for more information.                                          
                                                                                                                                                                                              
                                                                                                                                                                                              
          </body>                                                                                                                                                                             
         </html>                                                                                                                                                                              
ERROR    HTTPError: 400 Bad Request from https://test.pypi.org/legacy/                                                                                                                        
         The description failed to render for 'text/x-rst'. See https://test.pypi.org/help/#description-content-type for more information.

The error message does not say where in that the malformed or otherwise incorrect content occur. With a lot of trial and error I found the validation error was caused by the :scale: parameter to the image:: directive in my README.rst. When I removed the :scale: parameter the validation passed and the version was accepted by PyPI. I had specified :scale: 100% so removing it made no difference to the rendering of the document. When I uploaded a new version of my package last time (2024-08-04) the :scale: parameter was accepted by the PyPI reStructuredText validation. The package I uploaded then was streamlit-passwordless v0.6.0

Expected behavior

The PyPI reStructuredText validation should output a better error message of what caused the validation to fail and match the validation of the twine check --strict command.

Steps to reproduce

Create a new Python package containing a README.rst with the content below:

My Package Name
===============

|conda-forge|

.. |conda-forge| image:: https://img.shields.io/conda/vn/conda-forge/streamlit_passwordless?style=plastic
   :alt: conda-forge - Version
   :scale: 100%
   :target: https://anaconda.org/conda-forge/streamlit_passwordless
  1. Build a a distribution of the package with the command python -m build

  2. Run the command twine check --strict dist/* and the validation should pass.

  3. Run the command twine upload --repository testpypi --verbose dist/*

  4. Observe the error.

  5. Remove :scale: 100% from README.rst and rebuild the package with python -m build

  6. Repeat step 3 and 4

  7. No error about " The description failed to render" should occur.

My platform

OS : Ubuntu 24.04
python : v3.12.3 (conda)
python-build: v0.10.0
twine : v5.1.1

@antonlydell antonlydell added bug 🐛 requires triaging maintainers need to do initial inspection of issue labels Aug 18, 2024
@di
Copy link
Member

di commented Aug 18, 2024

Duplicate of pypa/readme_renderer#304.

@di di closed this as completed Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 requires triaging maintainers need to do initial inspection of issue
Projects
None yet
Development

No branches or pull requests

2 participants