object value errors do not all indicate which field was involved
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Compute (nova) |
Fix Released
|
Low
|
Paul Murray | ||
oslo.versionedobjects |
Fix Released
|
Low
|
Davanum Srinivas (DIMS) |
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_
i = instance.
This would this would result in a ValueError exception as follows:
Traceback (most recent call last):
File "/home/
i = instance.
File "/home/
super(Instance, self)._
File "/home/
setattr(self, key, kwargs[key])
File "/home/
field_value = field.coerce(self, name, value)
File "/home/
return self._type.
File "/home/
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
Changed in nova: | |
assignee: | nobody → Paul Murray (pmurray) |
Changed in nova: | |
importance: | Undecided → Low |
Changed in oslo.versionedobjects: | |
assignee: | nobody → Davanum Srinivas (DIMS) (dims-v) |
importance: | Undecided → Low |
status: | New → In Progress |
Changed in nova: | |
assignee: | Paul Murray (pmurray) → Davanum Srinivas (DIMS) (dims-v) |
Changed in nova: | |
assignee: | Davanum Srinivas (DIMS) (dims-v) → Paul Murray (pmurray) |
Changed in nova: | |
milestone: | none → liberty-1 |
status: | Fix Committed → Fix Released |
Changed in oslo.versionedobjects: | |
milestone: | none → 0.5.0 |
status: | Fix Committed → Fix Released |
Changed in nova: | |
milestone: | liberty-1 → 12.0.0 |
Fix proposed to branch: master /review. openstack. org/163328
Review: https:/