Include value in string Property type error

When a property value does not match the defined type of the property, we
include the offending value in the error message for all property types
except 'string'. This brings string properties into line with the other
types, for easier debugging.

Change-Id: I34ac7bad414403707f2e8a8f2dfbf804fa9bfaa7
Related-Bug: #1742646
changes/13/533013/2
Zane Bitter 5 years ago
parent d3614902dd
commit ccef7e2a78
  1. 2
      heat/engine/properties.py
  2. 8
      heat/tests/test_properties.py

@ -278,7 +278,7 @@ class Property(object):
if isinstance(value, (bool, int)):
value = six.text_type(value)
else:
raise ValueError(_('Value must be a string'))
raise ValueError(_('Value must be a string; got %r') % value)
return value
def _get_children(self, child_values, keys=None, validate=False,

@ -1687,15 +1687,15 @@ class PropertiesValidationTest(common.HeatTestCase):
schema = {'foo': {'Type': 'String'}}
props = properties.Properties(schema, {'foo': ['foo', 'bar']})
ex = self.assertRaises(exception.StackValidationFailed, props.validate)
self.assertEqual('Property error: foo: Value must be a string',
six.text_type(ex))
self.assertIn('Property error: foo: Value must be a string',
six.text_type(ex))
def test_dict_instead_string(self):
schema = {'foo': {'Type': 'String'}}
props = properties.Properties(schema, {'foo': {'foo': 'bar'}})
ex = self.assertRaises(exception.StackValidationFailed, props.validate)
self.assertEqual('Property error: foo: Value must be a string',
six.text_type(ex))
self.assertIn('Property error: foo: Value must be a string',
six.text_type(ex))
def test_none_string(self):
schema = {'foo': {'Type': 'String'}}

Loading…
Cancel
Save