So the body is a dict of dicts, where I guess the error message keys to the body, which is how the code expected it to work in novaclient.
>>> body = {"itemNotFound": {"message": "Flavor test could not be found.", "code
": 404}}
>>> body[list(body)[0]]
{'message': 'Flavor test could not be found.', 'code': 404}
>>>
But now we get something like:
{"message": "The resource could not be found.<br /><br />\n\n\n", "code": "404 Not Found", "title": "Not Found"}
Note that even with webob 1.5.1 the content-type in the response is application/json, so it doesn't really help us to key off that to handle this. We basically can't trust the format until we require at least webob>=1.6.0.
Here is what a 404 response looks like with novaclient and webob 1.5.1:
DEBUG (session:248) REQ: curl -g -i -X GET http:// 9.5.126. 108:8774/ v2.1/e4f68bae11 8f46fa986e3fd54 cbacb1e/ flavors/ test -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-OpenStack- Nova-API- Version: 2.25" -H "X-Auth-Token: {SHA1}8b87e089d 79ad483b178bdf6 73e9639ffd86d52 9" :387) "GET /v2.1/e4f68bae1 18f46fa986e3fd5 4cbacb1e/ flavors/ test HTTP/1.1" 404 77 Request- Id: req-d9df03b0- 4150-4b53- 8157-7560ccf39f 75 Vary: X-OpenStack- Nova-API- Version Connection: keep-alive X-Openstack- Nova-Api- Version: 2.25 Date: Fri, 18 Mar 2016 22:30:46 GMT Content-Type: application/json; charset=UTF-8
DEBUG (connectionpool
DEBUG (session:277) RESP: [404] Content-Length: 77 X-Compute-
RESP BODY: {"itemNotFound": {"message": "Flavor test could not be found.", "code": 404}}
So the body is a dict of dicts, where I guess the error message keys to the body, which is how the code expected it to work in novaclient.
>>> body = {"itemNotFound": {"message": "Flavor test could not be found.", "code
": 404}}
>>> body[list(body)[0]]
{'message': 'Flavor test could not be found.', 'code': 404}
>>>
But now we get something like:
{"message": "The resource could not be found.<br /><br />\n\n\n", "code": "404 Not Found", "title": "Not Found"}
Note that even with webob 1.5.1 the content-type in the response is application/json, so it doesn't really help us to key off that to handle this. We basically can't trust the format until we require at least webob>=1.6.0.