Fix #1982: pvesh: check if a handler exists for path

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@proxmox.com>
This commit is contained in:
Christian Ebner 2019-01-15 10:32:47 +01:00 committed by Thomas Lamprecht
parent e61f1629e7
commit 0abe2e035e

View File

@ -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});