1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

json_query, no more 'unknown type' errors (#2607)

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Brian Coca 2021-05-25 07:04:19 -04:00 committed by GitHub
parent 63012eef82
commit d871399220
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,3 @@
---
bugfixes:
- json_query filter plugin - avoid 'unknown type' errors for more Ansible internal types (https://github.com/ansible-collections/community.general/pull/2607).

View file

@ -35,9 +35,11 @@ def json_query(data, expr):
raise AnsibleError('You need to install "jmespath" prior to running '
'json_query filter')
# Hack to handle Ansible String Types
# Hack to handle Ansible Unsafe text, AnsibleMapping and AnsibleSequence
# See issue: https://github.com/ansible-collections/community.general/issues/320
jmespath.functions.REVERSE_TYPES_MAP['string'] = jmespath.functions.REVERSE_TYPES_MAP['string'] + ('AnsibleUnicode', 'AnsibleUnsafeText', )
jmespath.functions.REVERSE_TYPES_MAP['array'] = jmespath.functions.REVERSE_TYPES_MAP['array'] + ('AnsibleSequence', )
jmespath.functions.REVERSE_TYPES_MAP['object'] = jmespath.functions.REVERSE_TYPES_MAP['object'] + ('AnsibleMapping', )
try:
return jmespath.search(expr, data)
except jmespath.exceptions.JMESPathError as e: