`with_dict` type error include value in error message (#84473)

* with_dict better error message

* include type in error message

* changelog fragment

* Update lib/ansible/plugins/lookup/dict.py

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>

* specific wording

---------

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/84554/head
simonLeary42 11 months ago committed by GitHub
parent 4c30e8b6cf
commit e151cd765d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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.

@ -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

Loading…
Cancel
Save