From 9a49013287d9c7abfdb3cb7a3fd91aa140261f07 Mon Sep 17 00:00:00 2001 From: Ricardo Dias Date: Mon, 25 Jun 2018 10:30:25 +0100 Subject: [PATCH] mgr/dashboard: controllers: fix endpoint return type when method returns `bytes` Signed-off-by: Ricardo Dias --- src/pybind/mgr/dashboard/controllers/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pybind/mgr/dashboard/controllers/__init__.py b/src/pybind/mgr/dashboard/controllers/__init__.py index dfdb5fec57218..c9016d47dfbf1 100644 --- a/src/pybind/mgr/dashboard/controllers/__init__.py +++ b/src/pybind/mgr/dashboard/controllers/__init__.py @@ -542,6 +542,8 @@ class BaseController(object): kwargs.update(data.items()) ret = func(*args, **kwargs) + if isinstance(ret, bytes): + ret = ret.decode('utf-8') if json_response: cherrypy.response.headers['Content-Type'] = 'application/json' ret = json.dumps(ret).encode('utf8') -- 2.39.5