From 6e397345b1b4f5dc9e67cebde817155693f5cf51 Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Wed, 17 Jan 2018 21:01:29 -0800 Subject: [PATCH] Resolve unit test failures with going to oslo.serialization 2.3.0 openstack/oslo.serialization made a change in commit c1a7079c26d27a2e46cca26963d3d9aa040bdbe8 which changed how jsonutils.to_primitive() handles Exception objects. Previously the actual Exception object would be returned but now it returns a 'repr' of the object. This was done because CircularReferences were occuring in some use cases with Exceptions and also in version 3.0 of oslo.serialization they were going to raise a ValueError() for unhandled types and this change caused Exceptions to now be handled. The code previously would call the serialization function and if any unknown Exception occurred it would just return action_result. With the change to oslo.serialization an exception was no longer being raised and thus no Exception would be raised and caught. Now check if action_result is an Exception and if so return it. Closes-Bug: #1728368 Change-Id: Ic374ec891a65f603433091cdae27b0d4aac8362f --- glance/common/wsgi.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/glance/common/wsgi.py b/glance/common/wsgi.py index 6c8853da20..a94576b80d 100644 --- a/glance/common/wsgi.py +++ b/glance/common/wsgi.py @@ -1235,6 +1235,10 @@ class Resource(object): response = webob.exc.HTTPInternalServerError() return response + # We cannot serialize an Exception, so return the action_result + if isinstance(action_result, Exception): + return action_result + try: response = webob.Response(request=request) self.dispatch(self.serializer, action, response, action_result)