Not assignment variable 'image' in api.v2.image_data

Bug #1310952 reported by Sergey Nikitin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Undecided
Sergey Nikitin

Bug Description

Raise UnboundLocalError in 'try expect' block while catching exception using a var 'image'.

File "/opt/stack/glance/.tox/py27/local/lib/python2.7/site-packages/testtools/testcase.py", line 393, in assertRaises
    self.assertThat(our_callable, matcher)
  File "/opt/stack/glance/.tox/py27/local/lib/python2.7/site-packages/testtools/testcase.py", line 404, in assertThat
    mismatch_error = self._matchHelper(matchee, matcher, message, verbose)
  File "/opt/stack/glance/.tox/py27/local/lib/python2.7/site-packages/testtools/testcase.py", line 454, in _matchHelper
    mismatch = matcher.match(matchee)
  File "/opt/stack/glance/.tox/py27/local/lib/python2.7/site-packages/testtools/matchers/_exception.py", line 108, in match
    mismatch = self.exception_matcher.match(exc_info)
  File "/opt/stack/glance/.tox/py27/local/lib/python2.7/site-packages/testtools/matchers/_higherorder.py", line 62, in match
    mismatch = matcher.match(matchee)
  File "/opt/stack/glance/.tox/py27/local/lib/python2.7/site-packages/testtools/testcase.py", line 385, in match
    reraise(*matchee)
  File "/opt/stack/glance/.tox/py27/local/lib/python2.7/site-packages/testtools/matchers/_exception.py", line 101, in match
    result = matchee()
  File "/opt/stack/glance/.tox/py27/local/lib/python2.7/site-packages/testtools/testcase.py", line 902, in __call__
    return self._callable_object(*self._args, **self._kwargs)
  File "glance/common/utils.py", line 437, in wrapped
    return func(self, req, *args, **kwargs)
  File "glance/api/v2/image_data.py", line 120, in upload
    self._restore(image_repo, image)
UnboundLocalError: local variable 'image' referenced before assignment

Changed in glance:
assignee: nobody → Sergey Nikitin (snikitin)
Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix proposed to glance (master)

Fix proposed to branch: master
Review: https://review.openstack.org/89499

Changed in glance:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

Reviewed: https://review.openstack.org/89499
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=8241aef9291ba554f891da2d994c4b0795ef8002
Submitter: Jenkins
Branch: master

commit 8241aef9291ba554f891da2d994c4b0795ef8002
Author: Sergey Nikitin <email address hidden>
Date: Tue Apr 22 11:53:44 2014 +0400

    Assign local variable in api.v2.image_data

    If local variable 'image' will be not initialized we get UnboundLocalError
    while handle following exceptions:
    exception.StorageFull
    exception.StorageQuotaFull
    exception.ImageSizeLimitExceeded
    exception.StorageWriteDenied
    webob.exc.HTTPError
    ValueError

    This is because not initialized variable 'image' used as argument of
    method _restore. That is why we should initialize it.

    Closes-Bug: #1310952

    Change-Id: I3bf73ca272aad479416067495006476934a01dd9

Changed in glance:
status: In Progress → Fix Committed
Changed in glance:
milestone: none → juno-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in glance:
milestone: juno-2 → 2014.2
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.