[api] Exception while creating environment without name provided

Bug #1492703 reported by Lin Yang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Murano
Fix Released
Medium
Lin Yang

Bug Description

When created an environment with name provided in request body, it throw internal exception. It would be better to give back a more meaningful message and hide internal details.

Output is as following:

$ curl -X POST http://127.0.0.1:8082/v1/environments -H "X-Auth-Token: `gettoken`" -H "Content-Type: application/json" -d '{"abc": "abc"}'
{"explanation": "The resource could not be found.", "code": 404, "error": {"message": "'name'", "traceback": "Traceback (most recent call last):\n File \"/opt/stack/murano/murano/api/middleware/fault.py\", line 127, in process_request\n return req.get_response(self.application)\n File \"/usr/local/lib/python2.7/dist-packages/webob/request.py\", line 1317, in send\n application, catch_exc_info=False)\n File \"/usr/local/lib/python2.7/dist-packages/webob/request.py\", line 1281, in call_application\n app_iter = application(self.environ, start_response)\n File \"/usr/local/lib/python2.7/dist-packages/webob/dec.py\", line 130, in __call__\n resp = self.call_func(req, *args, **self.kwargs)\n File \"/usr/local/lib/python2.7/dist-packages/webob/dec.py\", line 195, in call_func\n return self.func(req, *args, **kwargs)\n File \"/usr/local/lib/python2.7/dist-packages/keystonemiddleware/auth_token/__init__.py\", line 434, in __call__\n response = req.get_response(self._app)\n File \"/usr/local/lib/python2.7/dist-packages/webob/request.py\", line 1317, in send\n application, catch_exc_info=False)\n File \"/usr/local/lib/python2.7/dist-packages/webob/request.py\", line 1281, in call_application\n app_iter = application(self.environ, start_response)\n File \"/usr/local/lib/python2.7/dist-packages/webob/dec.py\", line 130, in __call__\n resp = self.call_func(req, *args, **self.kwargs)\n File \"/usr/local/lib/python2.7/dist-packages/webob/dec.py\", line 195, in call_func\n return self.func(req, *args, **kwargs)\n File \"/opt/stack/murano/murano/common/wsgi.py\", line 197, in __call__\n response = req.get_response(self.application)\n File \"/usr/local/lib/python2.7/dist-packages/webob/request.py\", line 1317, in send\n application, catch_exc_info=False)\n File \"/usr/local/lib/python2.7/dist-packages/webob/request.py\", line 1281, in call_application\n app_iter = application(self.environ, start_response)\n File \"/usr/local/lib/python2.7/dist-packages/paste/urlmap.py\", line 216, in __call__\n return app(environ, start_response)\n File \"/usr/local/lib/python2.7/dist-packages/webob/dec.py\", line 144, in __call__\n return resp(environ, start_response)\n File \"/usr/local/lib/python2.7/dist-packages/routes/middleware.py\", line 136, in __call__\n response = self.app(environ, start_response)\n File \"/usr/local/lib/python2.7/dist-packages/webob/dec.py\", line 144, in __call__\n return resp(environ, start_response)\n File \"/usr/local/lib/python2.7/dist-packages/webob/dec.py\", line 130, in __call__\n resp = self.call_func(req, *args, **self.kwargs)\n File \"/usr/local/lib/python2.7/dist-packages/webob/dec.py\", line 195, in call_func\n return self.func(req, *args, **kwargs)\n File \"/opt/stack/murano/murano/common/wsgi.py\", line 414, in __call__\n action_result = self.execute_action(action, request, **action_args)\n File \"/opt/stack/murano/murano/common/wsgi.py\", line 429, in execute_action\n return self.dispatch(self.controller, action, request, **action_args)\n File \"/opt/stack/murano/murano/common/wsgi.py\", line 438, in dispatch\n return method(*args, **kwargs)\n File \"/opt/stack/murano/murano/api/v1/request_statistics.py\", line 57, in wrap\n result = func(*args, **kwargs)\n File \"/opt/stack/murano/murano/api/v1/environments.py\", line 66, in create\n name = unicode(body['name'])\nKeyError: 'name'\n", "type": "KeyError"}, "title": "Not Found"}

Lin Yang (lin-a-yang)
Changed in murano:
assignee: nobody → Lin Yang (lin-a-yang)
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/220800

Changed in murano:
status: New → In Progress
Changed in murano:
importance: Undecided → Medium
milestone: none → liberty-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to murano (master)

Reviewed: https://review.openstack.org/220800
Committed: https://git.openstack.org/cgit/openstack/murano/commit/?id=b6277155fe69df33542ff40275c07247f62387e8
Submitter: Jenkins
Branch: master

commit b6277155fe69df33542ff40275c07247f62387e8
Author: Lin Yang <email address hidden>
Date: Sun Sep 6 17:42:27 2015 +0800

    Improve error message in case no environment name

    When created environment without name provided in request body, it
    throw internal exception to user. So check whether name exist at
    first, if not, return HTTPBadRequest with more clear message to
    user.

    Change-Id: Ie0c0c9341b1084aae90ecfa7f7cf7b31e958902a
    Closes-Bug: #1492703

Changed in murano:
status: In Progress → Fix Committed
Changed in murano:
status: Fix Committed → Fix Released
Changed in murano:
milestone: liberty-3 → 1.0.0
Changed in murano:
milestone: 1.0.0 → 1.0.1
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.