Comment 0 for bug 1662228

Revision history for this message
Sam Betts (sambetts) wrote :

Error responses from the Ironic API return as a double JSON encoded error message. An example of this is: {"error_message": "{\"debuginfo\": null, \"faultcode\": \"Client\", \"faultstring\": \"The requested action \\\"provide\\\" can not be performed on node \\\"7c b3fb9f-780e-48ab-8e22-20dff73d4b1d\\\" while it is in state \\\"active\\\".\"}"}

The JSON dictionary inside of error_message does not need to be string encoded, this results in applications consuming the API to have to decode the outer body of the response and then (and only if the error_message exists) decode again the internal body of the message.

Even our own python-ironicclient falls victim to this: https://github.com/openstack/python-ironicclient/blob/master/ironicclient/common/http.py#L77

After some investigation it appears the response ends up encoded this way because of two separate places: https://github.com/openstack/wsme/blob/ecaf3aa40f0fc09a30bf2e47b42bf4c4314c1dc0/wsmeext/pecan.py#L109

and

https://github.com/openstack/ironic/blob/master/ironic/api/middleware/parsable_error.py#L35

The first place creates the {\"debuginfo\": null, \"faultcode\": \"Client\", \"faultstring\": \"The requested action \\\"provide\\\" can not be performed on node \\\"7c b3fb9f-780e-48ab-8e22-20dff73d4b1d\\\" while it is in state \\\"active\\\".\"} body, and then the middleware wraps it the second time.