404 Not Found error when querying PyPI JSON API for package metadata
0 reputation · 12 Jul 2021, 03:37 UTC
Goal
Develop a client that can gracefully handle cancellation and timeout scenarios when retrieving package metadata from the PyPI JSON API.
Constraints and Uncertainty
The API returns a 404 Not Found with a JSON body containing "Not found" for non‑existent packages, and a 429 Too many requests when the rate limit (~60 req/min) is exceeded. No timeout header or cancellation signal is exposed; clients must rely on their HTTP library’s timeout or cancellation mechanisms. The lack of a documented cancellation protocol is an open design decision that may be addressed in future releases.
Unresolved Questions
- Does PyPI provide any recommended pattern for canceling in‑progress requests, or is it entirely left to client libraries?
- What is the expected behavior when a client times out before receiving a response—should the client treat it as a transient error or a permanent failure?
- Will future PyPI releases introduce a timeout header or cancellation token to support graceful shutdown of long‑running requests?