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

[PR #5129/3c2d7eb1 backport][stable-5] dig: Fix evaluation of boolean parameters #5137

Conversation

patchback[bot]
Copy link

@patchback patchback bot commented Aug 20, 2022

This is a backport of PR #5129 as merged into main (3c2d7eb).

SUMMARY

Fixes evaluation of falsy boolean parameters in dig lookup plugin.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

community.general.dig lookup plugin

ADDITIONAL INFORMATION

Plugin currently uses bool() function to convert string boolean values to boolean type. This function in not the right one for this task as is returns True for every non-empty string:

Python 3.9.7 (default, Sep 13 2021, 08:18:39) 
[GCC 8.5.0 20210514 (Red Hat 8.5.0-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> bool('False')
True
>>> bool('no')
True

There is function in ansible.module_utils for this which correctly handles string-to-boolean conversion.

I also added tests for dig lookup and this issue specifically.

* Add lookup_dig tests

* Fix boolean evaluation

* Add changelog fragment

* Apply review changes

* Add license

(cherry picked from commit 3c2d7eb)
@ansibullbot
Copy link
Collaborator

cc @jpmens
click here for bot help

@ansibullbot ansibullbot added backport bug This issue/PR relates to a bug integration tests/integration lookup lookup plugin new_contributor Help guide this first time contributor plugins plugin (any type) tests tests labels Aug 20, 2022
@felixfontein felixfontein merged commit 2e11c2d into stable-5 Aug 20, 2022
@felixfontein felixfontein deleted the patchback/backports/stable-5/3c2d7eb193ac6676a054396c2d41328f23862104/pr-5129 branch August 20, 2022 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug integration tests/integration lookup lookup plugin new_contributor Help guide this first time contributor plugins plugin (any type) tests tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants