-
Notifications
You must be signed in to change notification settings - Fork 664
Description
The only HTTP status codes other than 200 that are currently used are 404 and 403 in the places you'd expect. Any other errors (e.g. validation failures while publishing a crate) are returned as a 200 response with a json object describing the error.
I took a look at all the current uses of util::errors::human
and they all seem to pretty nicely correspond to errors that should be a 400 Bad Request. I attempted this change but unfortunately cargo
does not handle getting responses with status code 400 nicely (rust-lang/cargo#3995).
Obviously this is something that may take a little finessing to not break existing cargo. Or the work required for that may make this not worth changing at all.
As a reason to do this other than just for consistency with HTTP APIs; I noticed this while attempting to get errors back to the UI in #697. When saving a data model Ember.js expects to either get back a response with status code 200 containing the saved model, or a response with an error status code containing the error messages. I can special case the validation errors, but this would introduce some inconsistency between different request handlers intended for the UI and request handlers intended for cargo.