* [pve-devel] [PATCH common] JSONSchema: property strings: handle boolean default_key consistently
@ 2025-09-12 9:39 Dominik Csapak
0 siblings, 0 replies; only message in thread
From: Dominik Csapak @ 2025-09-12 9:39 UTC (permalink / raw)
To: pve-devel
A schema with a default_key that is of type boolean, e.g.
```
enabled => {
type => 'boolean',
default_key = 1,
},
```
(can be found for example in qemu-server's 'agent' property)
depending on the sent value, we handled that differently:
when sending `enabled=true`, `parse_boolean` is used to convert it to
the object:
```
{
enabled => 1,
}
```
so our type checker is happy.
When sending `true` instead, this conversion does not happen, the
resulting object is:
```
{
enabled => "true",
}
```
and the type check fails with
`type check ('boolean') failed - got 'true'`
To fix this, also apply this conversion in the case when the default_key
is not given.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/PVE/JSONSchema.pm | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index d765533..c6e0f36 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -1090,6 +1090,9 @@ sub parse_property_string {
if ($format->{$key}->{default_key}) {
$default_key = $key;
if (!$res->{$default_key}) {
+ if ($format->{$key}->{type} && $format->{$key}->{type} eq 'boolean') {
+ $part = parse_boolean($part) // $part;
+ }
$res->{$default_key} = $part;
last;
}
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-09-12 9:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-12 9:39 [pve-devel] [PATCH common] JSONSchema: property strings: handle boolean default_key consistently Dominik Csapak
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.