mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-07 00:32:57 +00:00
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:
parent
e61f1629e7
commit
0abe2e035e
@ -208,17 +208,21 @@ sub resource_cap {
|
|||||||
sub extract_path_info {
|
sub extract_path_info {
|
||||||
my ($uri_param) = @_;
|
my ($uri_param) = @_;
|
||||||
|
|
||||||
my $info;
|
my ($handler, $info);
|
||||||
|
|
||||||
my $test_path_properties = sub {
|
my $test_path_properties = sub {
|
||||||
my ($method, $path) = @_;
|
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 (defined(my $cmd = $ARGV[0])) {
|
||||||
if (my $method = $method_map->{$cmd}) {
|
if (my $method = $method_map->{$cmd}) {
|
||||||
if (my $path = $ARGV[1]) {
|
if (my $path = $ARGV[1]) {
|
||||||
$test_path_properties->($method, $path);
|
$test_path_properties->($method, $path);
|
||||||
|
if (!defined($handler)) {
|
||||||
|
print STDERR "No '$cmd' handler defined for '$path'\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} elsif ($cmd eq 'bashcomplete') {
|
} elsif ($cmd eq 'bashcomplete') {
|
||||||
my $cmdline = substr($ENV{COMP_LINE}, 0, $ENV{COMP_POINT});
|
my $cmdline = substr($ENV{COMP_LINE}, 0, $ENV{COMP_POINT});
|
||||||
|
Loading…
Reference in New Issue
Block a user