← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1775863] [NEW] Cannot save a RequestSpec object if nothing changed

 

Public bug reported:

If a RequestSpec.save() is called on an object that has no changed field
the code blows up with UnboundLocalError:

      File "nova/tests/unit/objects/test_request_spec.py", line 622, in test_save_does_not_persist_requested_resources
        req_obj.save()
      File "/mnt/ssd/ebalgib/nova/py27/.tox/py27/local/lib/python2.7/site-packages/oslo_versionedobjects/base.py", line 226, in wrapper
        return fn(self, *args, **kwargs)
      File "nova/objects/request_spec.py", line 588, in save
        updates = self._get_update_primitives()
      File "nova/objects/request_spec.py", line 561, in _get_update_primitives
        return db_updates
    UnboundLocalError: local variable 'db_updates' referenced before assignment


It is because the db_updates local is only initialized if there is something to update but returned regardless
https://github.com/openstack/nova/blob/master/nova/objects/request_spec.py#L518
https://github.com/openstack/nova/blob/master/nova/objects/request_spec.py#L532

** Affects: nova
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1775863

Title:
  Cannot save a RequestSpec object if nothing changed

Status in OpenStack Compute (nova):
  New

Bug description:
  If a RequestSpec.save() is called on an object that has no changed
  field the code blows up with UnboundLocalError:

        File "nova/tests/unit/objects/test_request_spec.py", line 622, in test_save_does_not_persist_requested_resources
          req_obj.save()
        File "/mnt/ssd/ebalgib/nova/py27/.tox/py27/local/lib/python2.7/site-packages/oslo_versionedobjects/base.py", line 226, in wrapper
          return fn(self, *args, **kwargs)
        File "nova/objects/request_spec.py", line 588, in save
          updates = self._get_update_primitives()
        File "nova/objects/request_spec.py", line 561, in _get_update_primitives
          return db_updates
      UnboundLocalError: local variable 'db_updates' referenced before assignment

  
  It is because the db_updates local is only initialized if there is something to update but returned regardless
  https://github.com/openstack/nova/blob/master/nova/objects/request_spec.py#L518
  https://github.com/openstack/nova/blob/master/nova/objects/request_spec.py#L532

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1775863/+subscriptions


Follow ups