From: Kefu Chai Date: Thu, 15 Jun 2017 02:14:59 +0000 (+0800) Subject: pybind/mgr/restful: return 400 on bad request X-Git-Tag: v12.1.0~139^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9673f95f8d02694a77373ad3ff953755711a601a;p=ceph-ci.git pybind/mgr/restful: return 400 on bad request we should return 500 on that case. it's the client's fault not feeding us with expected requests. Signed-off-by: Kefu Chai --- diff --git a/src/pybind/mgr/restful/api/pool.py b/src/pybind/mgr/restful/api/pool.py index 0c8d2c92e63..a59e259cb62 100644 --- a/src/pybind/mgr/restful/api/pool.py +++ b/src/pybind/mgr/restful/api/pool.py @@ -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)