Skip to content

Commit b716193

Browse files
authored
Merge branch 'main' into wasi-support-pep
2 parents 5cbd8d3 + d34b798 commit b716193

1 file changed

Lines changed: 30 additions & 15 deletions

File tree

peps/pep-0694.rst

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Post-History: `27-Jun-2022 <https://discuss.python.org/t/pep-694-upload-2-0-api-
1212
`14-Apr-2025 <https://discuss.python.org/t/pep-694-pypi-upload-api-2-0/76316/9>`__
1313
`06-Aug-2025 <https://discuss.python.org/t/pep-694-pypi-upload-api-2-0-round-2/101483>`__
1414
`27-Sep-2025 <https://discuss.python.org/t/pep-694-pypi-upload-api-2-0-round-2/101483/31>`__
15+
`07-Dec-2025 <https://discuss.python.org/t/pep-694-pypi-upload-api-2-0-round-2/101483/35>`__
1516

1617

1718
Abstract
@@ -84,8 +85,8 @@ In addition, there are a number of major issues with the legacy API:
8485

8586
The new upload API proposed in this PEP provides ways to solve all of these problems, either directly or
8687
through an extensible approach, allowing servers to implement features such as resumable and parallel uploads.
87-
This upload API this PEP proposes provides better error reporting, a more robust release testing experience,
88-
and atomic and simultaneous publishing of all release artifacts.
88+
This upload API this PEP proposes provides better and more standardized error reporting, a more robust release
89+
testing experience, and atomic and simultaneous publishing of all release artifacts.
8990

9091
Legacy API
9192
==========
@@ -274,17 +275,26 @@ are determined by the index operator.
274275
Errors
275276
------
276277

278+
Unless otherwise specified, all error (4xx and 5xx) responses from the server **MUST** use the :rfc:`9457`
279+
(Problem Details for HTTP APIs) format. In particular, the server **MUST** use the "Problem Details JSON
280+
Object" defined in :rfc:`Section 3 <9457#section-3>` and **SHOULD** use the ``application/problem+json`` media
281+
type in its responses.
282+
277283
Clients in general should be prepared to handle `HTTP response error status codes
278-
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status>`_ which **MAY** contain payloads of the
279-
the following format:
284+
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status>`_ which **SHOULD** contain payloads like
285+
the following, although note that the details are index-specific, as long as they conform to RFC 9457. By way
286+
of example, PyPI could return the following error body:
280287

281288
.. code-block:: json
282289
283290
{
291+
"type": "https://docs.pypi.org/api/errors/error-types#invalid-filename",
292+
"status": 400,
293+
"title": "The artifact used an invalid wheel file name format",
294+
"details": "See https://packaging.python.org/en/latest/specifications/binary-distribution-format/",
284295
"meta": {
285296
"api-version": "2.0"
286297
},
287-
"message": "...",
288298
"errors": [
289299
{
290300
"source": "...",
@@ -293,11 +303,12 @@ the following format:
293303
]
294304
}
295305
296-
Besides the standard ``meta`` key, this has the following top level keys:
306+
RFC 9457 defines ``type``, ``status``, ``title``, and ``details``. The ``meta`` and ``errors`` keys are
307+
"extension members", defined in :rfc:`Section 3.2 <9457#section-3.2>`. The index **SHOULD** include these
308+
extension members.
297309

298-
``message``
299-
A singular message that encapsulates all errors that may have happened on this
300-
request.
310+
``meta``
311+
The same request/response metadata structure as defined in the :ref:`publishing-session` description.
301312

302313
``errors``
303314
An array of specific errors, each of which contains a ``source`` key, which is a string that
@@ -683,14 +694,14 @@ The request looks like:
683694
Besides the standard ``meta`` key, the request JSON has the following additional keys:
684695

685696
``filename`` (**required**)
686-
The name of the file being uploaded. The filename **MUST** conform to either the `source
687-
distribution file name specification
697+
The name of the file being uploaded. The filename **MUST** conform to either the `source distribution
698+
file name specification
688699
<https://packaging.python.org/en/latest/specifications/source-distribution-format/#source-distribution-file-name>`_
689700
or the `binary distribution file name convention
690701
<https://packaging.python.org/en/latest/specifications/binary-distribution-format/#file-name-convention>`_.
691-
Indexes **SHOULD** validate these file names at the time of the request, returning a ``400 Bad
692-
Request`` error code, as described in the :ref:`session-errors` section when the file names do
693-
not conform.
702+
Indexes **SHOULD** validate these file names at the time of the request, returning a ``400 Bad Request``
703+
error code and an RFC 9457 style error body, as described in the :ref:`session-errors` section when the
704+
file names do not conform.
694705

695706
``size`` (**required**)
696707
The size in bytes of the file being uploaded.
@@ -1094,7 +1105,11 @@ as experience is gained operating Upload 2.0.
10941105
Change History
10951106
==============
10961107

1097-
* `23-Sep-2025 <TBD>`__
1108+
* `06-Dec-2025 <TBD>`__
1109+
1110+
* Error responses conform to the :rfc:`9457` format.
1111+
1112+
* `23-Sep-2025 <https://discuss.python.org/t/pep-694-pypi-upload-api-2-0-round-2/101483/31>`__
10981113

10991114
* Remove the ``nonce`` and ``gentoken()`` algorithm. Indexes are now responsible for generating
11001115
an cryptographically secure session token and obfuscated stage URL (but only if they support

0 commit comments

Comments
 (0)