Skip to content

more detailed error handling in registry-api, show crates.io errors to user#3196

Merged
GuillaumeGomez merged 1 commit intorust-lang:mainfrom
syphar:graceful-crates-io-err
Feb 10, 2026
Merged

more detailed error handling in registry-api, show crates.io errors to user#3196
GuillaumeGomez merged 1 commit intorust-lang:mainfrom
syphar:graceful-crates-io-err

Conversation

@syphar
Copy link
Member

@syphar syphar commented Feb 9, 2026

Today I gave the registry api code a little love.

generally I wanted:

  • retry only when it's worth retrying (= on 5xx & connection errors)
  • parse the crates.io api error responses, and show the message to the user. For now I assume that 4xx responses are json / can be parsed, and 5xx are plain text.
  • use the status code we get from crates.io as our own status code.
  • use a enum as error type, so we can use the specific error information in the search-handler.
  • to move some tests from integration-like (where we tested crates.io api things via the search-handler in web::handlers::releases), to more unit-like tests directly on the RegistryApi struct.

In the code I discovered some code that tried to parse error messages out out successful responses. I assume that this is legacy, and dropped it. [To be safe, I also asked](#t-crates-io > api , error responses).

( I didn't put any time in design for the error message, feel free to improve)

@syphar syphar requested a review from a team as a code owner February 9, 2026 23:56
@syphar syphar self-assigned this Feb 9, 2026
@github-actions github-actions bot added the S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed label Feb 9, 2026
@GuillaumeGomez
Copy link
Member

Thanks!

@GuillaumeGomez GuillaumeGomez merged commit 8d6520a into rust-lang:main Feb 10, 2026
15 checks passed
@GuillaumeGomez GuillaumeGomez deleted the graceful-crates-io-err branch February 10, 2026 09:34
@github-actions github-actions bot added S-waiting-on-deploy This PR is ready to be merged, but is waiting for an admin to have time to deploy it and removed S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed labels Feb 10, 2026
@syphar syphar removed the S-waiting-on-deploy This PR is ready to be merged, but is waiting for an admin to have time to deploy it label Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants