From b81e77cfecf7ead5f1f2da836e5302f6987ac2ed Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 21 Aug 2014 13:24:53 -0500 Subject: [PATCH] Tweak error language in dict validation --- lib/ansible/utils/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index 401d35ed86..1e6a5383c0 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -699,16 +699,20 @@ def parse_kv(args): def _validate_both_dicts(a, b): if not (isinstance(a, dict) and isinstance(b, dict)): - raise errors.AnsibleError("Failed to combine two values which are not " - "both hashes, got these differing values now:\n\n%s\n and\n%s" % (a, b)) + raise errors.AnsibleError( + "failed to combine variables, expected dicts but got a '%s' and a '%s'" % (type(a).__name__, type(b).__name__) + ) def merge_hash(a, b): ''' recursively merges hash b into a keys from b take precedence over keys from a ''' - _validate_both_dicts(a, b) result = {} + # we check here as well as in combine_vars() since this + # function can work recursively with nested dicts + _validate_both_dicts(a, b) + for dicts in a, b: # next, iterate over b keys and values for k, v in dicts.iteritems():