REST API error responses are not consistent

Bug #1208620 reported by Luis A. Garcia
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Undecided
Luis A. Garcia

Bug Description

There was a recent change (commit c5ab336) to implement returning consistent errors in JSON or XML with a pre-defined schema so that those error responses can be parsed programmatically, however some errors are still coming back in plain text (not JSON or XML), regardless of the Accept header used.

For example:
Doing a GET /stacks/unknown-stack
Will yield a nice JSON response

{
   "explanation":"The resource could not be found.",
   "code":404,
   "error":{
      "message":"The Stack (unknown-stack) could not be found.",
      "traceback":"Traceback (most recent call last):\n\n File \"/opt/stack/heat/heat/openstack/common/rpc/amqp.py\", line 424, in _process_data\n **args)\n\n File \"/opt/stack/heat/heat/openstack/common/rpc/dispatcher.py\", line 172, in dispatch\n result = getattr(proxyobj, method)(ctxt, **kwargs)\n\n File \"/opt/stack/heat/heat/engine/service.py\", line 54, in wrapped\n return func(self, ctx, *args, **kwargs)\n\n File \"/opt/stack/heat/heat/engine/service.py\", line 147, in identify_stack\n raise exception.StackNotFound(stack_name=stack_name)\n\nStackNotFound: The Stack (unknown-stack) could not be found.\n",
      "type":"StackNotFound"
   },
   "title":"Not Found"
}

But doing a POST /stacks
Body: {}
Will yield the following plain text response:

400 Bad Request

No stack name specified

Luis A. Garcia (luisg-8)
Changed in heat:
assignee: nobody → Luis A. Garcia (luisg-8)
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

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

Changed in heat:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/40503
Committed: http://github.com/openstack/heat/commit/433da2654372cf6e1841b24266d3318c7d0c14af
Submitter: Jenkins
Branch: master

commit 433da2654372cf6e1841b24266d3318c7d0c14af
Author: Luis A. Garcia <email address hidden>
Date: Tue Aug 6 18:36:02 2013 +0000

    Ensure all REST API error responses are consistent

    Heat exceptions are serialized into JSON/XML responses by the fault app,
    which is at the end of the WSGI pipeline. Some REST API errors however
    are raised as HTTPExceptions, which are treated by WSGI as responses
    ready to be sent back to the user, and they can't reach the fault app.

    This patch set disguises HTTPExceptions raised by the wsgi.Resource so
    they can reach the app that will serialize them just like all other
    errors.

    Fixes bug 1208620

    Change-Id: Id98dbc1e3b208401be8f0119a6d72d4561a2221a

Changed in heat:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in heat:
milestone: none → havana-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: havana-3 → 2013.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.