]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/JSONSchema.pm
get_options: don't set optional positional params to `undef`
[pve-common.git] / src / PVE / JSONSchema.pm
index 20d72b317e801799bbc78f2f19c82ca126a73221..486454976824ec48aaf91274fa60639c10c09196 100644 (file)
@@ -1640,11 +1640,15 @@ sub get_options {
                if (!@$args) {
                    # check if all left-over arg_param are optional, else we
                    # must die as the mapping is then ambigious
-                   for (my $j = $i; $j < scalar(@$arg_param); $j++) {
-                       my $prop = $arg_param->[$j];
+                   for (; $i < scalar(@$arg_param); $i++) {
+                       my $prop = $arg_param->[$i];
                        raise("not enough arguments\n", code => HTTP_BAD_REQUEST)
                            if !$schema->{properties}->{$prop}->{optional};
                    }
+                   if ($arg_param->[-1] eq 'extra-args') {
+                       $opts->{'extra-args'} = [];
+                   }
+                   last;
                }
                $opts->{$arg_name} = shift @$args;
            }