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
This commit is contained in:
John L. Villalovos 2018-01-17 21:01:29 -08:00 committed by Brian Rosmaita
parent 631add1ba8
commit 6e397345b1
1 changed files with 4 additions and 0 deletions

View File

@ -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)