[PATCH ha-manager 1/2] api: assert validity of resources param only if defined

Michael Köppl
2026-03-24T12:49:40Z

The check for the validity of the resources param should only be
performed if the param was even defined, since it is not a required
parameter for updating a rule. Previously, when not setting the
resources field as part of the request, the check in the assert
function would fail due to using undefined as a hash reference, which
would stop users from updating a rule.

Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
src/PVE/API2/HA/Rules.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/API2/HA/Rules.pm b/src/PVE/API2/HA/Rules.pm
index f09ab36..0b44d51 100644
--- a/src/PVE/API2/HA/Rules.pm
+++ b/src/PVE/API2/HA/Rules.pm
@@ -343,7 +343,7 @@ __PACKAGE__->register_method({
my $plugin = PVE::HA::Rules->lookup($type);
my $opts = $plugin->check_config($ruleid, $param, 0, 1);

- $assert_valid_resources_param->($opts->{resources});
+ $assert_valid_resources_param->($opts->{resources}) if $opts->{resources};
$assert_valid_nodes_param->($opts->{nodes}) if $opts->{nodes};

my $options = $plugin->private()->{options}->{$type};
--
2.47.3