← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1430681] Re: object value errors do not all indicate which field was involved

 

** Also affects: oslo.versionedobjects
   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/1430681

Title:
  object value errors do not all indicate which field was involved

Status in OpenStack Compute (Nova):
  In Progress
Status in Oslo Versioned Objects:
  New

Bug description:
  When a value is assigned to an object field it is type checked in the
  coerce() method for the field and a ValueError exception is raised if
  it is not of the appropriate type. The name of the field involved in
  the check is known in the coerce() method, but in most cases it is not
  mentioned in the error message. When constructing an object with a
  list of field values it is hard to know which one caused the error.
  Adding the name of the field that generated the error would help.

  For example, this test:

      def test_my_dummy_test(self):
          i = instance.Instance(uuid='my id', system_metadata='metadata')

  This would this would result in a ValueError exception as follows:

  Traceback (most recent call last):
    File "/home/ptm/code/nova/nova/tests/unit/objects/test_instance.py", line 1514, in test_my_dummy_test
      i = instance.Instance(uuid='my id', system_metadata='metadata')
    File "/home/ptm/code/nova/nova/objects/instance.py", line 270, in __init__
      super(Instance, self).__init__(*args, **kwargs)
    File "/home/ptm/code/nova/nova/objects/base.py", line 282, in __init__
      setattr(self, key, kwargs[key])
    File "/home/ptm/code/nova/nova/objects/base.py", line 77, in setter
      field_value = field.coerce(self, name, value)
    File "/home/ptm/code/nova/nova/objects/fields.py", line 191, in coerce
      return self._type.coerce(obj, attr, value)
    File "/home/ptm/code/nova/nova/objects/fields.py", line 433, in coerce
      raise ValueError(_('A dict is required in field %s') % attr)
  ValueError: A dict is required here

  This does not give any clue which of the two values supplied is
  incorrect. Adding the field name to error message could give an error
  like this:

  ValueError: A dict is required in field system_metadata

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


References