]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/restful: return 400 on bad request 15646/head
authorKefu Chai <kchai@redhat.com>
Thu, 15 Jun 2017 02:14:59 +0000 (10:14 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 15 Jun 2017 07:09:27 +0000 (15:09 +0800)
we should return 500 on that case. it's the client's fault not feeding us
with expected requests.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/restful/api/pool.py

index 0c8d2c92e63afc23e45c1dd72888c29ef3194315..a59e259cb625256961b829645fbe9dc965ddb52e 100644 (file)
@@ -34,7 +34,11 @@ class PoolId(RestController):
         """
         Modify the information for the pool id
         """
-        args = request.json
+       try:
+            args = request.json
+        except ValueError:
+            response.status = 400
+            return {'message': 'Bad request: malformed JSON or wrong Content-Type'}
 
         # Get the pool info for its name
         pool = module.instance.get_pool_by_id(self.pool_id)