If the rule is not defined or does not have a type set, there are no
optional property defaults to set.

This prevents users of set_rule_defaults(...) to have to deal with
unnecessary error handling.

Fixes: https://bugzilla.proxmox.com/show_bug.cgi?id=7399
Signed-off-by: Daniel Kral <[email protected]>
---
 src/PVE/HA/Rules.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/PVE/HA/Rules.pm b/src/PVE/HA/Rules.pm
index 38c57548..3a14eeb3 100644
--- a/src/PVE/HA/Rules.pm
+++ b/src/PVE/HA/Rules.pm
@@ -274,7 +274,8 @@ haven't been explicitly set yet.
 sub set_rule_defaults {
     my ($class, $rule) = @_;
 
-    if (my $plugin = $class->lookup($rule->{type})) {
+    if ($rule && $rule->{type}) {
+        my $plugin = $class->lookup($rule->{type});
         my $properties = $plugin->properties();
 
         for my $prop (keys %$properties) {
-- 
2.47.3




Reply via email to