Pypi package upload errors due to violation of length check constraints

💥 Problem Summary

When we introduced new Pypi metadata fields with check constraints on the field lengths, we started encountering Pypi package upload errors when the package to be uploaded violates the check constraints.

See:

🚑 Solution

We don't want to remove the check constraints, as those prevent unbounded resource consumption of Package Registry.

We can follow the approach we did with the description field (!137000 (merged)) and the keywords field (!144983 (merged)): truncate the text if it is too long, and then upload the truncated text.

To prevent further errors, we should consider applying this approach on the other metadata fields that have check constraints:

  • summary (255 chars)
  • author_email (2048 chars)
  • required_python (255 chars)
  • metadata_version (16 chars)
  • description_content_type (128 chars)

Steps to reproduce

Build and attempt to upload a PyPI package with a summary longer than 255 chars.

What is the current bug behavior?

Uploading a package with a summary field (populated from description on pyproject.toml) results in an error:

INFO     Response from http://gdk.test:3000/api/v4/projects/7/packages/pypi:                                                                                                                                
         400 Bad Request                                                                                                                                                                                    
INFO     {"message":"400 Bad request - Validation failed: Summary is too long (maximum is 255 characters)"}                                                                                                 
ERROR    HTTPError: 400 Bad Request from http://gdk.test:3000/api/v4/projects/7/packages/pypi                                                                                                               
         Bad Request   

The package was not uploaded.

What is the expected correct behavior?

The package should upload without error.