[openstack-dev] [api][nova] Openstack HTTP error codes
everett.toews at RACKSPACE.COM
Fri Jan 30 21:00:52 UTC 2015
On Jan 29, 2015, at 11:41 AM, Sean Dague <sean at dague.net> wrote:
> Correct. This actually came up at the Nova mid cycle in a side
> conversation with Ironic and Neutron folks.
> HTTP error codes are not sufficiently granular to describe what happens
> when a REST service goes wrong, especially if it goes wrong in a way
> that would let the client do something other than blindly try the same
> request, or fail.
> Having a standard json error payload would be really nice.
> fault: ComputeFeatureUnsupportedOnInstanceType,
> messsage: "This compute feature is not supported on this kind of
> instance type. If you need this feature please use a different instance
> type. See your cloud provider for options."
> That would let us surface more specific errors.
> Today.... there is a giant hodgepodge - see:
> Especially blocks like this:
> if 'cloudServersFault' in resp_body:
> message =
> elif 'computeFault' in resp_body:
> message = resp_body['computeFault']['message']
> elif 'error' in resp_body:
> message = resp_body['error']['message']
> elif 'message' in resp_body:
> message = resp_body['message']
> Standardization here from the API WG would be really great.
Agreed. I’m 100% for having a guideline for errors. Good error messages is one of the most important aspects of a good developer experience for an API. I suspect that once you propose an error format for one error, people will immediately think of a lot of valid reasons to have a formant for many errors.
I did a bit of research into prior art for error messages. The best discussion I found on it starts over in JSON-API . It ultimately results in this error format . An example would look like
"title": "foobar must be in the range [foo, bar)"
Do we need to use every field in the format? No.
Can we add additional fields as we see fit? Yes.
We need to do what’s best for OpenStack so I’d like to use a format that’s somewhat a standard (at the very least it’s clear that the JSON-API folks have done a lot of thinking on it) but that’s flexible enough to meet our requirements.
I came across some other error formats such as  and  but found them to be a bit complicated or require things we don’t need.
Thoughts on the JSON-API error format or other formats?
More information about the OpenStack-dev