[pve-devel] [PATCH pve-manager 1/1] Fix #1982 Check handler exists

Christian Ebner c.ebner at proxmox.com
Tue Jan 15 10:32:47 CET 2019


Checks that the handler for the API call even exists before verifying the
parameter schema. By this the reported error message is more descriptive.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
 PVE/CLI/pvesh.pm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/PVE/CLI/pvesh.pm b/PVE/CLI/pvesh.pm
index 41e27a00..9b8e3245 100755
--- a/PVE/CLI/pvesh.pm
+++ b/PVE/CLI/pvesh.pm
@@ -208,17 +208,21 @@ sub resource_cap {
 sub extract_path_info {
     my ($uri_param) = @_;
 
-    my $info;
+    my ($handler, $info);
 
     my $test_path_properties = sub {
 	my ($method, $path) = @_;
-	(undef, $info) = PVE::API2->find_handler($method, $path, $uri_param);
+	($handler, $info) = PVE::API2->find_handler($method, $path, $uri_param);
     };
 
     if (defined(my $cmd = $ARGV[0])) {
 	if (my $method = $method_map->{$cmd}) {
 	    if (my $path = $ARGV[1]) {
 		$test_path_properties->($method, $path);
+		if (!defined($handler)) {
+		    print STDERR "No '$cmd' handler defined for '$path'\n";
+		    exit(1);
+		}
 	    }
 	} elsif ($cmd eq 'bashcomplete') {
 	    my $cmdline = substr($ENV{COMP_LINE}, 0, $ENV{COMP_POINT});
-- 
2.11.0




More information about the pve-devel mailing list