From 9673f95f8d02694a77373ad3ff953755711a601a Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 15 Jun 2017 10:14:59 +0800 Subject: [PATCH] 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 --- src/pybind/mgr/restful/api/pool.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) -- 2.39.5