diff --git a/masakari/exception.py b/masakari/exception.py index 7ce938b3..704d7cac 100644 --- a/masakari/exception.py +++ b/masakari/exception.py @@ -44,7 +44,7 @@ CONF = masakari.conf.CONF class ConvertedException(webob.exc.WSGIHTTPException): def __init__(self, code, title="", explanation=""): - self.code = code + self.code = int(code) # There is a strict rule about constructing status line for HTTP: # '...Status-Line, consisting of the protocol version followed by a # numeric status code and its associated textual phrase, with each diff --git a/masakari/tests/unit/api/openstack/test_wsgi.py b/masakari/tests/unit/api/openstack/test_wsgi.py index 9866be40..9e05bdc4 100644 --- a/masakari/tests/unit/api/openstack/test_wsgi.py +++ b/masakari/tests/unit/api/openstack/test_wsgi.py @@ -253,8 +253,9 @@ class ResourceTest(MicroversionedTest): @extensions.expected_errors(HTTPStatus.BAD_REQUEST) def create(self, req, body): if expected_body != body: - msg = "The request body invalid" - raise webob.exc.HTTPBadRequest(explanation=msg) + raise exception.ConvertedException( + code=HTTPStatus.BAD_REQUEST, + explanation="The request body invalid") return "success" # verify the method: POST app = fakes.TestRouter(Controller()) diff --git a/releasenotes/notes/bug-1932194-2b721860bbc26819.yaml b/releasenotes/notes/bug-1932194-2b721860bbc26819.yaml new file mode 100644 index 00000000..87281294 --- /dev/null +++ b/releasenotes/notes/bug-1932194-2b721860bbc26819.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes Masakari API to properly return error codes for invalid requests + to the user instead of 500. + `LP#1932194 `__