diff --git a/heat/api/openstack/v1/stacks.py b/heat/api/openstack/v1/stacks.py index 9cb39495f4..853334debf 100644 --- a/heat/api/openstack/v1/stacks.py +++ b/heat/api/openstack/v1/stacks.py @@ -71,9 +71,10 @@ class InstantiationData(object): return environment_format.parse(data) else: return template_format.parse(data) - except ValueError: - err_reason = _("%s not in valid format") % data_type - raise exc.HTTPBadRequest(err_reason) + except ValueError as parse_ex: + mdict = {'type': data_type, 'error': parse_ex} + msg = _("%(type)s not in valid format: %(error)s") % mdict + raise exc.HTTPBadRequest(msg) def stack_name(self): """ diff --git a/heat/tests/test_api_openstack_v1.py b/heat/tests/test_api_openstack_v1.py index 8f4197038e..e0ad05d0fc 100644 --- a/heat/tests/test_api_openstack_v1.py +++ b/heat/tests/test_api_openstack_v1.py @@ -71,6 +71,20 @@ class InstantiationDataTest(HeatTestCase): stacks.InstantiationData.format_parse, '!@#$%^¬ json', 'Garbage') + def test_format_parse_invalid_message(self): + # make sure the parser error gets through to the caller. + bad_temp = ''' +parameters: + KeyName: + type: string + description: bla + ''' + + parse_ex = self.assertRaises(webob.exc.HTTPBadRequest, + stacks.InstantiationData.format_parse, + bad_temp, 'foo') + self.assertIn('line 3, column 3', str(parse_ex)) + def test_stack_name(self): body = {'stack_name': 'wibble'} data = stacks.InstantiationData(body)