PEP 847: Problem Details for the Simple Repository API

Pre-PEP thread: Pre-PEP Discussion: RFC 9457 Error Responses for Package registries

Current PEP text: PEP 847 – Problem Details for the Simple Repository API | peps.python.org

Summary of rationale and motivation

Right now, there is no standard way for package indices (i.e. services offering the Simple Repository API) to present useful error messages to users. As a result, package installers (pip, Poetry, uv) have generally converged on the lowest common denominator of rendering the HTTP status code along with its phrase.

This is suboptimal because it’s (1) generic, meaning that indices with different authentication and access patterns can’t present useful errors, and (2) becoming even more generic with the adoption of HTTP/2, since HTTP/2 no longer allows origins to customize the status phrase itself.

(Generic as in “supplies very little information,” not as in “general.” It’s the opposite of general too!)

Summary of proposed changes

This PEP proposes the adoption of RFC 9457-style “problem details” as a uniform error representation for the Simple Repository API. The main advantages of this approach are that it’s backwards compatible (both in terms of HTTP semantics and how existing installers behave), as well as progressively enhanceable (servers can insert as little or as much context as they find useful into a standard, structured error response format).

I recommend looking at Appendix 1 for some (purely hypothetical) examples of how problem details can be presented by servers and rendered by clients!

As always, I look forward to the community’s feedback on this proposal :slightly_smiling_face:

CC @dstufft as sponsor/delegate

CC @zsol and @lgonzalez as co-authors

10 Likes

I do not really have any notes on the PEP so I am just here to say thank you for it! This will be a huge quality of life improvement for me as someone who maintains a mirror being able to provide back better error messaging to users.

3 Likes

It’s been almost two weeks since I opened this, so I’m just giving it a little bump/nudge to remind people to provide feedback, if they have any! I suspect this PEP isn’t very controversial but regardless :slightly_smiling_face:

I’m personally mostly happy with it, no blockers from me.


If you want to have clients programmatically act on different problem types, you’ll need to predefine values for type (either the whole URI or just the URL path part).

The primary HTTP status I would say clients should be able to distinguish is item (package or file) not found versus invalid location (URL path).

We had some early discussion about that, but I decided to leave it out of this PEP! I think in practice it’ll be hard to make standard programmatic suggestions here, due to the diversity in third-party indices. But the nice thing about RFC 9457 is that we can always revisit that :slightly_smiling_face:

3 Likes

It’s been just over two weeks, so I’m hereby requesting pronouncement on this PEP from @dstufft!

4 Likes