Fix for 699654 breaks exception handling if args is empty

Bug #709510 reported by Vish Ishaya
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Tushar Patil

Bug Description

The fix for 699654 which uses exception.args[0] breaks if args is empty and covers up the underlying exception. For example:

Traceback (most recent call last):
 File "/usr/lib/pymodules/python2.6/eventlet/wsgi.py", line 336, in handle_one_response
   result = self.application(self.environ, start_response)
 File "/usr/lib/pymodules/python2.6/paste/urlmap.py", line 203, in __call__
   return app(environ, start_response)
 File "/usr/lib/pymodules/python2.6/webob/dec.py", line 147, in __call__
   resp = self.call_func(req, *args, **self.kwargs)
 File "/usr/lib/pymodules/python2.6/webob/dec.py", line 208, in call_func
   return self.func(req, *args, **kwargs)
 File "/usr/lib/pymodules/python2.6/nova/api/ec2/__init__.py", line 59, in __call__
   rv = req.get_response(self.application)
 File "/usr/lib/pymodules/python2.6/webob/request.py", line 919, in get_response
   application, catch_exc_info=False)
 File "/usr/lib/pymodules/python2.6/webob/request.py", line 887, in call_application
   app_iter = application(self.environ, start_response)
 File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
   return resp(environ, start_response)
 File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
   return resp(environ, start_response)
 File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
   return resp(environ, start_response)
 File "/usr/lib/pymodules/python2.6/webob/dec.py", line 147, in __call__
   resp = self.call_func(req, *args, **self.kwargs)
 File "/usr/lib/pymodules/python2.6/webob/dec.py", line 208, in call_func
   return self.func(req, *args, **kwargs)
 File "/usr/lib/pymodules/python2.6/nova/api/ec2/__init__.py", line 328, in __call__
   LOG.exception(_('Unexpected error raised: %s'), ex.args[0],
IndexError: tuple index out of range

Perhaps we should coerce the exceptions to unicode instead?

Related branches

Revision history for this message
Tushar Patil (tpatil) wrote :
Download full text (3.3 KiB)

Please test with the below patch. If see any problem in this patch please let me know. Thanks.

=== modified file 'nova/api/ec2/__init__.py'
--- nova/api/ec2/__init__.py 2011-01-27 22:10:42 +0000
+++ nova/api/ec2/__init__.py 2011-01-29 00:03:03 +0000
@@ -171,7 +171,7 @@
                     req.path)
         # Be explicit for what exceptions are 403, the rest bubble as 500
         except (exception.NotFound, exception.NotAuthorized) as ex:
- LOG.audit(_("Authentication Failure: %s"), ex.args[0])
+ LOG.audit(_("Authentication Failure: %s"), utils.utf8(ex))
             raise webob.exc.HTTPForbidden()

         # Authenticated!
@@ -316,30 +316,31 @@
         try:
             result = api_request.invoke(context)
         except exception.InstanceNotFound as ex:
- LOG.info(_('InstanceNotFound raised: %s'), ex.args[0],
+ LOG.info(_('InstanceNotFound raised: %s'), utils.utf8(ex),
                      context=context)
             ec2_id = cloud.id_to_ec2_id(ex.instance_id)
             message = _('Instance %s not found') % ec2_id
             return self._error(req, context, type(ex).__name__, message)
         except exception.VolumeNotFound as ex:
- LOG.info(_('VolumeNotFound raised: %s'), ex.args[0],
+ LOG.info(_('VolumeNotFound raised: %s'), utils.utf8(ex),
                      context=context)
             ec2_id = cloud.id_to_ec2_id(ex.volume_id, 'vol-%08x')
             message = _('Volume %s not found') % ec2_id
             return self._error(req, context, type(ex).__name__, message)
         except exception.NotFound as ex:
- LOG.info(_('NotFound raised: %s'), ex.args[0], context=context)
- return self._error(req, context, type(ex).__name__, ex.args[0])
+ LOG.info(_('NotFound raised: %s'), utils.utf8(ex), context=context)
+ return self._error(req, context, type(ex).__name__, utils.utf8(ex))
         except exception.ApiError as ex:
- LOG.exception(_('ApiError raised: %s'), ex.args[0],
+ LOG.exception(_('ApiError raised: %s'), utils.utf8(ex),
                           context=context)
             if ex.code:
- return self._error(req, context, ex.code, ex.args[0])
+ return self._error(req, context, ex.code, utils.utf8(ex))
             else:
- return self._error(req, context, type(ex).__name__, ex.args[0])
+ return self._error(req, context, type(ex).__name_,
+ utils.utf8(ex))
         except Exception as ex:
             extra = {'environment': req.environ}
- LOG.exception(_('Unexpected error raised: %s'), ex.args[0],
+ LOG.exception(_('Unexpected error raised: %s'), utils.utf8(ex),
                           extra=extra, context=context)
             return self._error(req,
                                context,

=== modified file 'nova/utils.py'
--- nova/utils.py 2011-01-27 19:52:10 +0000
+++ nova/utils.py 2011-01-28 23:45:43 +0000
@@ -405,6 +405,12 @@
     """
     if isinstance(value, unicode):
         return value.encode...

Read more...

Thierry Carrez (ttx)
Changed in nova:
importance: Undecided → Medium
status: New → Confirmed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → bexar-rc
Tushar Patil (tpatil)
Changed in nova:
assignee: nobody → Tushar Patil (tpatil)
status: Confirmed → In Progress
Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: bexar-rc → 2011.1
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.