diff --git a/changelogs/fragments/84473-dict-lookup-type-error-message.yml b/changelogs/fragments/84473-dict-lookup-type-error-message.yml new file mode 100644 index 00000000000..cefc5b96788 --- /dev/null +++ b/changelogs/fragments/84473-dict-lookup-type-error-message.yml @@ -0,0 +1,2 @@ +minor_changes: + - when the ``dict`` lookup is given a non-dict argument, show the value of the argument and its type in the error message. diff --git a/lib/ansible/plugins/lookup/dict.py b/lib/ansible/plugins/lookup/dict.py index a8c108974ff..c9b35b13bca 100644 --- a/lib/ansible/plugins/lookup/dict.py +++ b/lib/ansible/plugins/lookup/dict.py @@ -70,7 +70,7 @@ class LookupModule(LookupBase): for term in terms: # Expect any type of Mapping, notably hostvars if not isinstance(term, Mapping): - raise AnsibleError("with_dict expects a dict") + raise AnsibleError(f"the 'dict' lookup plugin expects a dictionary, got '{term}' of type {type(term)})") results.extend(self._flatten_hash_to_list(term)) return results