[pve-devel] applied: [PATCH common] RESTHandler getopt_usage: schema properties can be undef

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Mar 9 12:28:46 CET 2020


While seldom some of our API endpoints do not define it, e.g., the
world readable /access/ticket call.

As all of the stack can cope with that just fine make getopt_usage
also follow that behavior and don't assume that properties has to be
defined.

This fixes a complaint about undefined value use in the following
calls:
 pvesh usage /access/ticket
 pmgsh help /access

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/RESTHandler.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/PVE/RESTHandler.pm b/src/PVE/RESTHandler.pm
index 299bf68..60731ac 100644
--- a/src/PVE/RESTHandler.pm
+++ b/src/PVE/RESTHandler.pm
@@ -621,7 +621,10 @@ sub getopt_usage {
 
     my $schema = $info->{parameters};
     my $name = $info->{name};
-    my $prop = { %{$schema->{properties}} }; # copy
+    my $prop =  {};
+    if ($schema->{properties}) {
+	$prop = { %{$schema->{properties}} }; # copy
+    }
 
     my $has_output_format_option = $formatter_properties->{'output-format'} ? 1 : 0;
 
-- 
2.20.1





More information about the pve-devel mailing list