Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always nicely show errors from crates.io if possible #6771

Merged
merged 1 commit into from
Mar 21, 2019

Commits on Mar 21, 2019

  1. Always nicely show errors from crates.io if possible

    Currently if Cargo ever gets a non-200 response, it will either not show
    the error at all (if it was a 403 or 404), or spit out the entire
    response body. Historically crates.io has served a 200 for most errors
    to work around this, but we've stopped doing this as it causes problems
    for other clients.
    
    Additionally, we're starting to server more errors that have semantic
    meaning (429 for rate limiting, 503 when we're in read only mode). If
    the request specifies "Accept: application/json", we should ideally
    return the errors formatted nicely. This isn't always true, but it's
    what we'd like to do going forward.
    
    While the output that Cargo puts out at least contains the actual
    message, it's buried under a ton of useless info. This changes the
    behavior so that if the response was valid JSON in the format that Cargo
    expects, it just shows that (along with a description of the response
    status), and only falls back to spitting out everything if it can't
    parse the response body.
    
    I'd love to add some more tests for this, but I've had trouble finding
    anywhere in the test suite that exercises these paths.
    sgrif committed Mar 21, 2019
    Configuration menu
    Copy the full SHA
    9759340 View commit details
    Browse the repository at this point in the history