From 5da90ebee2a8213ebed41087454171799d5a30e4 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Mon, 18 Aug 2014 13:27:44 +1000 Subject: [PATCH] Make Fn::Join give a better error message When something goes wrong at the moment users are left staring hard at their template trying to figure out whats wrong. We can make this a lot easier by showing them the failed object. Change-Id: If87447b7e160591505a68d857e8ef1751aac3723 --- heat/engine/cfn/functions.py | 3 ++- heat/tests/test_parser.py | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/heat/engine/cfn/functions.py b/heat/engine/cfn/functions.py index c976439efa..2d600f6cf8 100644 --- a/heat/engine/cfn/functions.py +++ b/heat/engine/cfn/functions.py @@ -302,7 +302,8 @@ class Join(function.Function): if s is None: return '' if not isinstance(s, basestring): - raise TypeError(_('Items to join must be strings')) + raise TypeError( + _('Items to join must be strings %s') % (repr(s)[:200])) return s return delim.join(ensure_string(s) for s in strings) diff --git a/heat/tests/test_parser.py b/heat/tests/test_parser.py index d841bd6bfd..5af1635818 100644 --- a/heat/tests/test_parser.py +++ b/heat/tests/test_parser.py @@ -852,6 +852,14 @@ class ResolveDataTest(HeatTestCase): [' ', ['foo', 'bar']]}, 'baz']]} self.assertEqual('foo bar\nbaz', self.resolve(raw)) + def test_join_not_string(self): + snippet = {'Fn::Join': ['\n', [{'Fn::Join': + [' ', ['foo', 45]]}, 'baz']]} + error = self.assertRaises(TypeError, + self.resolve, + snippet) + self.assertIn('45', six.text_type(error)) + def test_base64_replace(self): raw = {'Fn::Base64': {'Fn::Replace': [ {'foo': 'bar'}, 'Meet at the foo']}}