fix only_if type conversion bug#203
Merged
whotwagner merged 2 commits intoait-testbed:developmentfrom Feb 12, 2026
Merged
Conversation
whotwagner
approved these changes
Feb 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR relates to #202
When compare_value method of the Conditional sees ast.Constant it always tries to convert it to an integer with return int(name.value). --> assumed all constants are integers, but ast.Constant can hold any literal value (strings, numbers, booleans, etc.). Solution: returning name.value directly instead of int(name.value), Python's built-in comparison operators will handle type checking.
playbook content:
Contents of demo_int.yml:
Contents of demo_str.yml:
Additionally fixes test test/conditionals.py
Explanation.
The test is wrong because it misunderstands how Python's is operator works versus how the Conditional class implements it. == compares values (equality), is compares identity
in python 1 is True is always FALSE because 1 is an integer object and True is a boolean object.

Before this PR both cast to integer let test pass