From: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-manager] fix #7942: pvesh: treat schema without properties as empty object
Date: Wed, 19 Aug 2026 11:50:23 +0200 [thread overview]
Message-ID: <20260819095023.329117-1-a.bied-charreton@proxmox.com> (raw)
merge_properties() dispatches on the shape of the target schema by
merging into `properties` if present, appending to an `allOf` list, or
wrapping a `oneOf` into a new `allOf`. A schema with none of those
entries died on the assumption that it is not an object.
A lot of endpoints (e.g., /cluster/firewall/options,
/cluster/notifications/matcher-field-values) across our api define the
parameters schema as follows:
{ additionalProperties => 0 }
Before 874d160f317a, pvesh treated this as a valid schema allowing no
parameters. Since that commit, it fails while loading with the
following error:
unknown schema type (not an object?)
Split the fallback branch into the three cases that can reach it: die
with the offending type if the schema is explicitly not an object, die
with the offending keys if it contains unexpected keys, otherwise treat
`$to` as a valid, empty object and populate `properties` directly.
Fixes: 874d160f317a ("pvesh: support for allOf/oneOf parameter schemas")
Fixes: https://bugzilla.proxmox.com/show_bug.cgi?id=7942
Signed-off-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
---
PVE/CLI/pvesh.pm | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/PVE/CLI/pvesh.pm b/PVE/CLI/pvesh.pm
index 0ff481d4..9568e22b 100755
--- a/PVE/CLI/pvesh.pm
+++ b/PVE/CLI/pvesh.pm
@@ -304,6 +304,12 @@ my $our_properties = {
},
};
+my sub unknown_schema_keys {
+ my ($schema) = @_;
+
+ return [grep { $_ ne 'additionalProperties' && $_ ne 'type' } keys $schema->%*];
+}
+
my sub merge_properties {
my ($from, $to) = @_;
@@ -323,7 +329,14 @@ my sub merge_properties {
my $old = { $to->%* };
$to->%* = (allOf => [$old, $from]);
} else {
- die "unknown schema type (not an object?)\n";
+ die "unknown schema type '$to->{type}' (not an object)\n"
+ if defined($to->{type}) && $to->{type} ne 'object';
+
+ my $unknown = unknown_schema_keys($to);
+ die "unknown schema type, found unexpected keys: " . join(', ', sort($unknown->@*)) . "\n"
+ if $unknown->@*;
+
+ $to->{properties} = { $from->{properties}->%* };
}
}
--
2.47.3
reply other threads:[~2026-08-19 9:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260819095023.329117-1-a.bied-charreton@proxmox.com \
--to=a.bied-charreton@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.