Skip to content

PEP 694: Abstract file upload mechanisms #4431

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ewdurbin
Copy link
Member

@ewdurbin ewdurbin commented May 21, 2025

This attempts to defer the implementation details of getting the bits of a given artifact from the client to the server.

The primary motivation here is to decouple this PEP from resumable/multi-part uploads, provide flexibility to implementers of PEP 694, and allow for new upload mechanisms without a PEP cycle.


📚 Documentation preview 📚: https://pep-previews--4431.org.readthedocs.build/

@ewdurbin
Copy link
Member Author

I spent some time to sketch this out as a Finite State Machine in pypi/warehouse#18174, and will be using what I learned to refine this a bit!

@ewdurbin ewdurbin marked this pull request as ready for review May 28, 2025 14:13
@ewdurbin ewdurbin requested review from dstufft and warsaw as code owners May 28, 2025 14:13
@ewdurbin
Copy link
Member Author

@dstufft @warsaw I think this is ready for a proper review.

@warsaw
Copy link
Member

warsaw commented May 28, 2025

I'm planning on taking a closer look later today.

Copy link
Member

@dstufft dstufft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple comments, but overall the changes look good to me.

I just wanted to note a few things I came across when reading the entire PEP (with these changes incorporated-- and probably a number of these came from my original PEP so that's on me :D ).

  • The PEP specifies that the endpoint for PyPI will be https://upload.pypi.org/2.0. I would probably remove that from the PEP and let PyPI decide what it's endpoint will be (in particular the /2.0 part is somewhat confusing given the PEP also uses conneg).
  • The PEP calls out the inability to parallelize or resume an upload as a problem to be solved, and then later states the PEP solves all the identified problems. The TUS based approach didn't really solve parallelization to begin with, and the removal of TUS means the PEP also doesn't solve resuming an uploading. I think that's fine, but we should update the wording.
  • The content type handling is kind of wonky I think. Much like PEP 691 the client can use the Accept header to request a particular content type from the server, and the server includes the full version number in the meta.api-version key in the response. However, the requests appear to only be using the meta.api-version key. I think ideally we want to have requests using a correct Content-Type for their request (and the latest wouldn't be supported here), and have the server use that for handling the request data. We probably want to also explicitly require that the meta.api-version matches the Content-Type for major version.

File Upload Mechanisms
----------------------

File Upload Mechanisms, with the exception of ``http-post-application-octet-stream`` are left as an
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if, instead of treating http-post-application-octet-stream as special, if we should treat this somewhat like how content types are treated?

In other words, basically define a registry of mechanisms (and in this PEP, the only one that is defined is http-post-application-octet-stream), but leave the door open that we can add other standard mechanisms to that registry in the future through future PEPs.

It may also make sense to further take a page from how content types are handled, and say that non-standard mechanisms have to start with vnd- to prevent namespace collisions. So a PyPI specific one would be vnd-pypi-whatever.

If a server intendes to match the behavior of another server's implementation, it **MAY** respond
with that implementation's file upload mechanism name.

All implementations of this PEP **MUST** implement the ``http-post-application-octet-stream`` file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can kind of guess what this mechanism is based on the name, but it would probably be a good idea to spell out what this mechanism entails (I assume it's just a HTTP POST with the contents of the file as the body).

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

Successfully merging this pull request may close these issues.

5 participants