[api] Should return JSON/XML error response bodies

Bug #1328662 reported by Steve McLellan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Murano
Fix Released
High
Ekaterina Chernova

Bug Description

As an example: create a valid package zip, and import it with:

murano package-import ~/git/my-murano-apps/sjm.murano.test.zip Hippopotamus

Because, unfortunately, Hippopotamus is not a valid category, the server rejects the package with a 400 error. All the client see is:

INFO Starting new HTTP connection (1): 15.126.207.137
INFO Starting new HTTP connection (1): localhost
HTTPBadRequest (HTTP 400)

In a number of places the client code traps non-OK response codes and returns exceptions.from_response which creates HTTP exceptions from response codes. In the process it hides the body of the exception. The fix isn't as simple as passing 'response.content' to from_response, however, since the API is returning HTTP errors.

I think the right fix is to put some middleware on top of the request to return either XML or JSON-serialized exception messages (based on the content-type header or Accepts header of the request) - see heat/api/middleware/fault.py for an example.

After this, the client can show a useful error message, and the dashboard should be able to do similarly.

Changed in murano:
importance: Undecided → Medium
status: New → Confirmed
Changed in murano:
assignee: nobody → Serg Melikyan (smelikyan)
milestone: none → juno-3
Changed in murano:
assignee: Serg Melikyan (smelikyan) → nobody
Changed in murano:
importance: Medium → High
Changed in murano:
assignee: nobody → Ekaterina Chernova (efedorova)
Revision history for this message
Ekaterina Chernova (efedorova) wrote :

Exceptions should be reworked at the top level. The blueprint is created https://blueprints.launchpad.net/murano/+spec/muano-api-exception-handling

Revision history for this message
Steve McLellan (sjmc7) wrote :

I don't dispute there is some reworking required, but the API should never return HTTP content type responses. Look at https://github.com/openstack/heat/blob/master/heat/api/middleware/fault.py#L54 for an example; it maps all inbuilt exceptions into webob exceptions.

Changed in murano:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-muranoclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/117780

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to murano (master)

Fix proposed to branch: master
Review: https://review.openstack.org/117782

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to murano (master)

Reviewed: https://review.openstack.org/117782
Committed: https://git.openstack.org/cgit/stackforge/murano/commit/?id=4ba60da712b7d288028fa553788acf141b8c0c58
Submitter: Jenkins
Branch: master

commit 4ba60da712b7d288028fa553788acf141b8c0c58
Author: Ekaterina Fedorova <email address hidden>
Date: Fri Aug 29 12:47:05 2014 +0400

    Apply fault middleware

    * Provide exceptions details in the response body
    * Decode package exception message to keep correct formatting

    Partly-Closes-Bug: #1328662
    Change-Id: I28000ec42db644d5db75f92d968955f7dd620091

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-muranoclient (master)

Reviewed: https://review.openstack.org/117780
Committed: https://git.openstack.org/cgit/stackforge/python-muranoclient/commit/?id=92ed07f3d9f7366668683ae92386fad49600d7d9
Submitter: Jenkins
Branch: master

commit 92ed07f3d9f7366668683ae92386fad49600d7d9
Author: Ekaterina Fedorova <email address hidden>
Date: Fri Aug 29 17:43:29 2014 +0400

    Log response when using requests library

    Also, add logging if response body is not empty
    and convertable to utf-8

    Change-Id: I3ad90d3e30b36cdb6ac39e7eed62626ea91202b4
    Closes-Bug: #1328662

Changed in murano:
status: In Progress → Fix Committed
ruhe (ruhe)
Changed in murano:
milestone: juno-3 → juno-rc1
Changed in murano:
status: Fix Committed → Fix Released
Changed in murano:
milestone: juno-rc1 → 2014.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.