Does it make sense to standardize index error responses?

This is something I’ve been thinking about recently, since it came up with how PEP 807 plans to encode its error responses.

TL;DR: the current simple index standards (PEP 503 / PEP 691 and their living forms) adequately describe the shape of successful index responses, but not the shape of failure responses. As a result, installer clients (pip, uv, poetry, etc.) frequently have to assume a lowest common denominator of HTTP error code semantics, which in turn are frequently sparse or inaccurate (e.g. an index returning 404 because the client lacks access to a package, rather than because that package doesn’t exist).

For example, with PyPI, error responses are always plain text regardless of the negotiated success response:

$ curl 'https://pypi.org/simple/rlsgkljsgfslgjb/' -H 'Accept: application/vnd.pypi.simple.v1+json'
404 Not Found

whereas other indices may return HTML, JSON, or another differently structured but still plaintext response.

I’m curious if people have thoughts on this – if there’s ample interest, I’ll turn this into a pre-PEP discussion with some rough ideas on how we could accomplish this in a backwards compatible way :slightly_smiling_face:

2 Likes

For some other context see Block download of components when violating policy – I don’t have insight into what most private indices do (besides pyx of course), but I’d expect that most would be able to take advantage of a standardized index error response.

I am happy to take part in some discussion around this. We are currently working on improving the experience ourselves (at the moment not as a PEP standard)

1 Like