From: Mikolaj Kucharski Subject: Re: Ansible 11.8.0 and JMESPathError in json_query filter plugin, invalid type To: ports@openbsd.org Cc: Pavel Korovin Date: Wed, 6 Aug 2025 17:31:13 +0000 Hi Stuart. Sure. See inlined patch below. On Wed, Aug 06, 2025 at 06:02:21PM +0100, Stuart Henderson wrote: > please use ${PATCHORIG} not .orig.port > Index: Makefile =================================================================== RCS file: /cvs/ports/sysutils/ansible/Makefile,v diff -u -p -u -r1.207 Makefile --- Makefile 17 Jul 2025 20:44:55 -0000 1.207 +++ Makefile 6 Aug 2025 17:27:29 -0000 @@ -2,6 +2,7 @@ COMMENT = radically simple IT automatio MODPY_DISTV = 11.8.0 DISTNAME = ansible-${MODPY_DISTV} +REVISION = 0 CATEGORIES = sysutils @@ -22,7 +23,7 @@ RUN_DEPENDS = sysutils/ansible-core>=2. post-install: ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/ansible ${INSTALL_DATA} ${WRKSRC}/CHANGELOG-v*.rst ${PREFIX}/share/doc/ansible - find ${PREFIX} -type f \( -name '.*' -o -name '*.orig' \) -delete + find ${PREFIX} -type f \( -name '.*' -o -name '*.orig' -o -name '*${PATCHORIG}' \) -delete find ${PREFIX} -type d \( -name '.*' -o -name changelogs \ -o -name docs -o -name tests \) -exec rm -rf {} + Index: patches/patch-ansible_collections_community_general_plugins_filter_json_query_py =================================================================== RCS file: patches/patch-ansible_collections_community_general_plugins_filter_json_query_py diff -N patches/patch-ansible_collections_community_general_plugins_filter_json_query_py --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-ansible_collections_community_general_plugins_filter_json_query_py 6 Aug 2025 17:27:29 -0000 @@ -0,0 +1,28 @@ +# json_query: extend list of type aliases for compatibility with ansible-core 2.19 +- https://github.com/ansible-collections/community.general/pull/10539 + +Index: ansible_collections/community/general/plugins/filter/json_query.py +--- ansible_collections/community/general/plugins/filter/json_query.py.orig ++++ ansible_collections/community/general/plugins/filter/json_query.py +@@ -124,10 +124,17 @@ def json_query(data, expr): + 'json_query filter') + + # 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', ) ++ # See issues https://github.com/ansible-collections/community.general/issues/320 ++ # and https://github.com/ansible/ansible/issues/85600. ++ jmespath.functions.REVERSE_TYPES_MAP['string'] = jmespath.functions.REVERSE_TYPES_MAP['string'] + ( ++ 'AnsibleUnicode', 'AnsibleUnsafeText', '_AnsibleTaggedStr', ++ ) ++ jmespath.functions.REVERSE_TYPES_MAP['array'] = jmespath.functions.REVERSE_TYPES_MAP['array'] + ( ++ 'AnsibleSequence', '_AnsibleLazyTemplateList', ++ ) ++ jmespath.functions.REVERSE_TYPES_MAP['object'] = jmespath.functions.REVERSE_TYPES_MAP['object'] + ( ++ 'AnsibleMapping', '_AnsibleLazyTemplateDict', ++ ) + try: + return jmespath.search(expr, data) + except jmespath.exceptions.JMESPathError as e: Index: patches/patch-ansible_collections_community_general_tests_integration_targets_filter_json_query_tasks_main_yml =================================================================== RCS file: patches/patch-ansible_collections_community_general_tests_integration_targets_filter_json_query_tasks_main_yml diff -N patches/patch-ansible_collections_community_general_tests_integration_targets_filter_json_query_tasks_main_yml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-ansible_collections_community_general_tests_integration_targets_filter_json_query_tasks_main_yml 6 Aug 2025 17:27:29 -0000 @@ -0,0 +1,31 @@ +# json_query: extend list of type aliases for compatibility with ansible-core 2.19 +- https://github.com/ansible-collections/community.general/pull/10539 + +Index: ansible_collections/community/general/tests/integration/targets/filter_json_query/tasks/main.yml +--- ansible_collections/community/general/tests/integration/targets/filter_json_query/tasks/main.yml.orig ++++ ansible_collections/community/general/tests/integration/targets/filter_json_query/tasks/main.yml +@@ -11,4 +11,23 @@ + - name: Test json_query filter + assert: + that: +- - "users | community.general.json_query('[*].hosts[].host') == ['host_a', 'host_b', 'host_c', 'host_d']" ++ - >- ++ users | community.general.json_query('[*].hosts[].host') == ['host_a', 'host_b', 'host_c', 'host_d'] ++ - >- ++ ports | json_query("[?contains(ports, `22`)]") == [ports[0]] ++ - >- ++ ports | json_query("[?contains(rule_desc, `ssh`)]") == [ports[0]] ++ - >- ++ my_complex_data | json_query('users[?id==`1`]') == [my_complex_data['users'][0]] ++ vars: ++ my_complex_data: ++ users: ++ - id: 1 ++ name: Alice ++ roles: ["admin", "dev"] ++ status: active ++ ports: ++ - ports: [22] ++ rule_desc: "ssh" ++ - ports: [80] ++ rule_desc: "http" -- Regards, Mikolaj