diff options
author | simonLeary42 <71396965+simonLeary42@users.noreply.github.com> | 2025-01-14 16:21:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-14 16:21:56 +0100 |
commit | e151cd765d45fb7b4e370536a584a09e36511613 (patch) | |
tree | c8db4caf1ca79dcb3230c60ab77aeeae0fbd55d3 | |
parent | .github: simplify PR templates (#84536) (diff) | |
download | ansible-e151cd765d45fb7b4e370536a584a09e36511613.tar.xz ansible-e151cd765d45fb7b4e370536a584a09e36511613.zip |
`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>
-rw-r--r-- | changelogs/fragments/84473-dict-lookup-type-error-message.yml | 2 | ||||
-rw-r--r-- | lib/ansible/plugins/lookup/dict.py | 2 |
2 files changed, 3 insertions, 1 deletions
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 0000000000..cefc5b9678 --- /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 a8c108974f..c9b35b13bc 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 |