Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed 'plugins/json_query.py' to use jebabin's solution to issue #27299 #30653

Closed
wants to merge 3 commits into from
Closed

Conversation

bdlamprecht
Copy link

@bdlamprecht bdlamprecht commented Sep 20, 2017

SUMMARY

Submitting this PR as a solution for Issue #27299 .

This change uses the python library ast to resolve some issues that arise from using certain query strings including starts_with, contains, and others.

This solution was from @jebabin . I'm submitting the PR because even though I don't understand the fix completely, it seems a simple enough of a fix to include future releases of Ansible (possibly even back-porting to other releases of Ansible 2.4).

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

json_query

ANSIBLE VERSION
ansible --version
ansible 2.5.0 (devel 140ea7f5ff) last updated 2017/09/20 13:14:52 (GMT -600)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/usr/share/my_modules']
  ansible python module location = /home/bl839s/ansible/lib/ansible
  executable location = /home/bl839s/ansible/bin/ansible
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
ADDITIONAL INFORMATION

See Issue #27299 for details.

Before:

PLAY [json_query testing] ****************************************************************************

TASK [debug] *****************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "JMESPathError in json_query filter plugin:\nIn function contains(), invalid type for value: irb.1111, expected one of: ['array', 'string'], received: \"unknown\""}

PLAY RECAP *******************************************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1

After:

PLAY [json_query testing] ****************************************************************************

TASK [debug] *****************************************************************************************
ok: [localhost] => (item={u'interface': u'irb.1111', u'address': u'10.0.1.1/29'}) => {
    "item": {
        "address": "10.0.1.1/29",
        "interface": "irb.1111"
    }
}
ok: [localhost] => (item={u'interface': u'irb.1114', u'address': u'10.0.2.1/29'}) => {
    "item": {
        "address": "10.0.2.1/29",
        "interface": "irb.1114"
    }
}
ok: [localhost] => (item={u'interface': u'irb.1114', u'address': u'fe80::b/112'}) => {
    "item": {
        "address": "fe80::b/112",
        "interface": "irb.1114"
    }
}

PLAY RECAP *******************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0

@ansibot
Copy link
Contributor

ansibot commented Sep 20, 2017

@bdlamprecht This PR contains @ mentions in at least one commit message. Those mentions can cause cascading notifications through GitHub and need to be removed. Please squash or amend your commits to remove the mentions.

click here for bot help

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 bugfix_pull_request needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. needs_triage Needs a first human triage before being processed. plugins/filter support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Sep 20, 2017
@bdlamprecht bdlamprecht changed the title Changed 'plugins/json_query.py' to use @jebabin's solution to issue #27299 Changed 'plugins/json_query.py' to use jebabin's solution to issue #27299 Sep 20, 2017
@bdlamprecht
Copy link
Author

bdlamprecht commented Sep 20, 2017

Fixed the @ issue mentioned in the commit message by ansibot above.

@ansibot
Copy link
Contributor

ansibot commented Sep 20, 2017

The test ansible-test sanity --test pep8 [?] failed with the following errors:

lib/ansible/plugins/filter/json_query.py:32:1: E303 too many blank lines (3)
lib/ansible/plugins/filter/json_query.py:51:1: E302 expected 2 blank lines, found 1

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Sep 20, 2017

The test ansible-test sanity --test pep8 [?] failed with the following error:

lib/ansible/plugins/filter/json_query.py:50:1: E302 expected 2 blank lines, found 1

click here for bot help

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Sep 20, 2017
Sorry about the previous commit not including the fix.
Brand new developer here.
@ansibot ansibot removed ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Sep 21, 2017
@s-hertel s-hertel removed the needs_triage Needs a first human triage before being processed. label Sep 22, 2017
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Sep 30, 2017
@ansibot ansibot added the new_contributor This PR is the first contribution by a new community member. label Oct 18, 2017
@ansibot ansibot removed the new_contributor This PR is the first contribution by a new community member. label Nov 3, 2017
@ansibot ansibot added needs_repo This PR no longer has an associated branch as it was removed by the submitter. new_contributor This PR is the first contribution by a new community member. labels Feb 6, 2018
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bugfix_pull_request labels Mar 2, 2018
@ansibot ansibot added support:community This issue/PR relates to code supported by the Ansible community. and removed support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Sep 18, 2018
@ansibot ansibot added the community_review In order to be merged, this PR must follow the community review workflow. label Oct 25, 2018
@ansibot ansibot removed the community_review In order to be merged, this PR must follow the community review workflow. label Nov 26, 2018
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed support:community This issue/PR relates to code supported by the Ansible community. labels Nov 26, 2018
Copy link
Contributor

@gundalow gundalow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want, this it will needs tests

@bdlamprecht
Copy link
Author

At this point, I don't care what happens with the PR seeing as it is so old.
I don't have the time to write the tests, so unless someone else is willing to, feel free to close out this PR.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Dec 7, 2018
@ansibot
Copy link
Contributor

ansibot commented Dec 15, 2018

@bdlamprecht Your branch does not contain a shippable.yml file. Please rebase your branch to trigger running of current tests.

click here for bot help

@ansibot ansibot added needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_shippable This PR lacks a shippable.yml in its tree. Please rebase your branch to include the latest CI tests. support:community This issue/PR relates to code supported by the Ansible community. and removed support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Dec 15, 2018
@gundalow
Copy link
Contributor

gundalow commented Sep 3, 2019

Given #30653 (comment) closing.

@gundalow gundalow closed this Sep 3, 2019
@gundalow gundalow added the pr_day Has been reviewed during a PR review Day label Sep 3, 2019
@ansible ansible locked and limited conversation to collaborators Oct 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. has_issue needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_repo This PR no longer has an associated branch as it was removed by the submitter. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. needs_shippable This PR lacks a shippable.yml in its tree. Please rebase your branch to include the latest CI tests. new_contributor This PR is the first contribution by a new community member. plugins/filter pr_day Has been reviewed during a PR review Day stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants