api: more permissive boolean checks#477
Merged
Merged
Conversation
At the moment, we strictly enforce boolean values to be one of the JSON defined "false" or "true". However, our Python client passes Python values such as "True" or "False". The API won't throw an error, it will simply reject the value and default to "False", which can lead to misleading behavior. Similarly to Openstack Nova [1], we'll accept a broader set of values that can be converted to boolean, such as "True", "T", "Y", "yes", "1". To do so, we'll reuse the strutils.bool_from_string helper [2]. [1] https://github.com/openstack/nova/blob/9e1434d255f59f10c0fdf75c3fe6bebfa315df10/nova/api/validation/parameter_types.py#L206-L212 [2] https://github.com/openstack/oslo.utils/blob/2efc66aeedf27c1a51345d377ddd4407d7db489c/oslo_utils/strutils.py#L187-L204
Dany9966
approved these changes
Jul 24, 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.
At the moment, we strictly enforce boolean values to be one of the JSON defined "false" or "true".
However, our Python client passes Python values such as "True" or "False". The API won't throw an error, it will simply reject the value and default to "False", which can lead to misleading behavior.
Similarly to Openstack Nova [1], we'll accept a broader set of values that can be converted to boolean, such as "True", "T", "Y", "yes", "1". To do so, we'll reuse the strutils.bool_from_string helper [2].
[1] https://github.com/openstack/nova/blob/9e1434d255f59f10c0fdf75c3fe6bebfa315df10/nova/api/validation/parameter_types.py#L206-L212
[2] https://github.com/openstack/oslo.utils/blob/2efc66aeedf27c1a51345d377ddd4407d7db489c/oslo_utils/strutils.py#L187-L204