diff --git a/heat/engine/template_common.py b/heat/engine/template_common.py index fb5557a070..63afd2dc19 100644 --- a/heat/engine/template_common.py +++ b/heat/engine/template_common.py @@ -98,6 +98,14 @@ class CommonTemplate(template.Template): name, data, no_parse) if isinstance(depends, six.string_types): depends = [depends] + elif depends: + for dep in depends: + if not isinstance(dep, six.string_types): + msg = _('Resource %(name)s %(key)s ' + 'must be a list of strings') % { + 'name': name, 'key': self.RES_DEPENDS_ON} + raise exception.StackValidationFailed(message=msg) + yield 'depends', depends del_policy = self._parse_resource_field(self.RES_DELETION_POLICY, diff --git a/heat/tests/test_validate.py b/heat/tests/test_validate.py index d2f885abf1..97974e9e38 100644 --- a/heat/tests/test_validate.py +++ b/heat/tests/test_validate.py @@ -2105,3 +2105,21 @@ parameters: 'NoEcho': 'false', 'Type': 'String'}}} self.assertEqual(expected, res) + + def test_validate_bad_depends(self): + test_template = ''' + heat_template_version: 2013-05-23 + + resources: + random_str: + type: OS::Heat::RandomString + depends_on: [{foo: bar}] + ''' + + t = template_format.parse(test_template) + + res = dict(self.engine.validate_template(self.ctx, t, {})) + self.assertEqual( + {'Error': 'Resource random_str depends_on must be ' + 'a list of strings'}, + res)