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

nb_lookup: Multiple same-type "api_filter" arguments unsupported #246

Closed
clearly-tyler-whitney opened this issue Jun 26, 2020 · 3 comments · Fixed by #250
Closed

nb_lookup: Multiple same-type "api_filter" arguments unsupported #246

clearly-tyler-whitney opened this issue Jun 26, 2020 · 3 comments · Fixed by #250
Labels
bug Something isn't working

Comments

@clearly-tyler-whitney
Copy link
Contributor

ISSUE TYPE
  • Bug Report
SOFTWARE VERSIONS
Ansible: 2.9.9
Netbox: 2.8.6
Collection: 0.2.3
SUMMARY

When trying to pass multiple "api_filter" arguments of a common type, the resulting GET is flattened to the last supplied value only.

STEPS TO REPRODUCE
- debug:
    msg: "{{ query('nb_lookup', 'devices', api_endpoint=netbox_url, token=netbox_token,
                    api_filter='role=foo role=bar status=active status=planned'
                    ) }}"
EXPECTED RESULTS

Return a list of dicts: devices having either "foo" or "bar" roles, and status of either "active" or "planned".

"GET /api/dcim/devices/?q=&role=foo&role=bar&status=active&status=planned HTTP/1.0" 200
ACTUAL RESULTS
"GET /api/dcim/devices/?role=bar&status=planned HTTP/1.0" 200
@clearly-tyler-whitney clearly-tyler-whitney changed the title Multiple same-type "api_filter" arguments unsupported nb_lookup: Multiple same-type "api_filter" arguments unsupported Jun 26, 2020
@FragmentedPacket
Copy link
Contributor

I will look further into a fix for this. I believe the reason this happens is because is creates a dictionary when parsing what the user passes in, and since there are duplicate keys, it uses the last one.

@FragmentedPacket
Copy link
Contributor

Do you mind testing #250 ?

I believe this issue should be fixed by that PR.

@clearly-tyler-whitney
Copy link
Contributor Author

Seems to work as advertised. Thanks for the fix. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants