Skip to content

api: more permissive boolean checks#477

Merged
Dany9966 merged 1 commit into
cloudbase:masterfrom
petrutlucian94:bool_parsing
Jul 24, 2026
Merged

api: more permissive boolean checks#477
Dany9966 merged 1 commit into
cloudbase:masterfrom
petrutlucian94:bool_parsing

Conversation

@petrutlucian94

@petrutlucian94 petrutlucian94 commented Jul 23, 2026

Copy link
Copy Markdown
Member

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.

2026-07-23 14:01:55.792 INFO coriolis.api.wsgi [req-f8b281c5-d6fb-4f21-b94c-88bebb315d27] GET https://127.0.0.1:7667/v1/2317193629ba4a7e99f47ecc1c2d2e75/endpoints/56322f6e-04e5-4aa8-a725-c2d52a2d6d21/instances?refresh=True
2026-07-23 14:01:55.811 WARNING coriolis.api.v1.utils [req-f8b281c5-d6fb-4f21-b94c-88bebb315d27] failed to parse refresh: Expecting value: line 1 column 1 (char 0): json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2026-07-23 14:01:55.811 INFO coriolis.api.v1.endpoint_instances [req-f8b281c5-d6fb-4f21-b94c-88bebb315d27] >>> Getting instances, refresh: False

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

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
Dany9966 merged commit c587e4c into cloudbase:master Jul 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants