Skip to content

Commit 72f9e08

Browse files
committed
Add FAQ entries explaining why project name and version are required at session creation.
1 parent 5e9d4b6 commit 72f9e08

File tree

1 file changed

+58
-5
lines changed

1 file changed

+58
-5
lines changed

peps/pep-0694.rst

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -703,11 +703,9 @@ The request looks like:
703703
Besides the standard ``meta`` key, the request JSON has the following additional keys:
704704

705705
``filename`` (**required**)
706-
The name of the file being uploaded. The filename **MUST** conform to either the `source distribution
707-
file name specification
708-
<https://packaging.python.org/en/latest/specifications/source-distribution-format/#source-distribution-file-name>`_
709-
or the `binary distribution file name convention
710-
<https://packaging.python.org/en/latest/specifications/binary-distribution-format/#file-name-convention>`_.
706+
The name of the file being uploaded. The filename **MUST** conform to either the
707+
`source distribution file name specification <sdist-filename-spec_>`_
708+
or the `binary distribution file name convention <wheel-filename-spec_>`_.
711709
Indexes **SHOULD** validate these file names at the time of the request, returning a ``400 Bad Request``
712710
error code and an RFC 9457 style error body, as described in the :ref:`session-errors` section when the
713711
file names do not conform.
@@ -1274,6 +1272,57 @@ index could define :ref:`index-specific metadata <index-specific-metadata>` to,
12741272
an organization of which the publisher is a member, to own the new project.
12751273

12761274

1275+
Why is the project name required when creating a publishing session?
1276+
--------------------------------------------------------------------
1277+
1278+
The project name is required at session creation because index permissions are fundamentally
1279+
tied to project ownership. Users have roles and permissions on specific projects, and these
1280+
permissions must be verified before any uploads can proceed.
1281+
1282+
Requiring the project name upfront provides several benefits:
1283+
1284+
**Immediate permission validation**: The server can verify that the authenticated user has
1285+
upload permission for the project at session creation time, failing fast with a clear error
1286+
rather than discovering permission issues after files have been uploaded.
1287+
1288+
**Simplified error handling**: If a session could span multiple projects, a permission failure
1289+
on one project mid-upload would leave the session in a complex partial state. With a single
1290+
project per session, permission errors are unambiguous.
1291+
1292+
**Trusted Publisher compatibility**: Indexes like PyPI support `Trusted Publishers
1293+
<https://docs.pypi.org/trusted-publishers/>`__ where OIDC tokens are scoped to specific projects.
1294+
A single-project session aligns naturally with this authentication model.
1295+
1296+
**Quota enforcement**: Projects may have different upload quotas or size limits. Validating
1297+
these constraints upfront is simpler when the project is known at session creation.
1298+
1299+
**Atomic release semantics**: A publishing session represents an atomic release of a single
1300+
project version. Allowing multiple projects would fundamentally change this model and
1301+
complicate the definition of what "publish" means for a session.
1302+
1303+
1304+
Why is the version required when creating a publishing session?
1305+
---------------------------------------------------------------
1306+
1307+
The version is required at session creation to establish a validation contract before any file
1308+
uploads begin. Since artifact filenames encode the version (per the `sdist <sdist-filename-spec_>`_
1309+
and `wheel <wheel-filename-spec_>`_ filename specifications), the server can validate that all
1310+
uploaded files match the declared version.
1311+
1312+
This design enables deterministic behavior with :ref:`parallel uploads <client-recommendations>`.
1313+
If the version were optional and inferred from the first uploaded file, a race condition would
1314+
occur when multiple files are uploaded in parallel: whichever upload the server processes first
1315+
would "win" and establish the version, causing other uploads with mismatched versions to fail
1316+
non-deterministically.
1317+
1318+
By requiring the version upfront, all parallel uploads validate against the same declared version.
1319+
A file with a mismatched version always fails, regardless of upload timing or order.
1320+
1321+
For :ref:`name registration <publishing-session-create>` where no artifacts are uploaded, the
1322+
version can be any valid placeholder (e.g., ``"0.0.0a0"``) since it is ignored when no files are
1323+
included in the session.
1324+
1325+
12771326
Open Questions
12781327
==============
12791328

@@ -1311,6 +1360,9 @@ as experience is gained operating Upload 2.0.
13111360
.. [#fn-immutable] Published files may still be yanked (i.e. :pep:`592`) or `deleted
13121361
<https://pypi.org/help/#file-name-reuse>`__ as normal.
13131362
1363+
.. _sdist-filename-spec: https://packaging.python.org/en/latest/specifications/source-distribution-format/#source-distribution-file-name
1364+
.. _wheel-filename-spec: https://packaging.python.org/en/latest/specifications/binary-distribution-format/#file-name-convention
1365+
13141366

13151367
Change History
13161368
==============
@@ -1323,6 +1375,7 @@ Change History
13231375
endpoints are now used only for ``GET`` (status) and ``DELETE`` (cancel) operations.
13241376
* Add non-normative :ref:`Recommendations for Client Implementers <client-recommendations>` section
13251377
with suggested UX patterns for tools like twine, uv, and GitHub Actions.
1378+
* Add FAQ entries explaining why project name and version are required at session creation.
13261379

13271380
* `06-Dec-2025 <https://discuss.python.org/t/pep-694-pypi-upload-api-2-0-round-2/101483/35>`__
13281381

0 commit comments

Comments
 (0)