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"}
Fix proposed to branch: master /review. openstack. org/220800
Review: https:/