When a path pointing to below a leaf endpoint is provided, for example '/access/acl/foobar', then when reaching the leaf endpoint, there is neither a regex nor subfolders to continue the lookup. This is fully expected, but currently an 'internal error' message will be returned and the only caller will log it to syslog. Returning undef instead avoids the misleading error log while otherwise preserving the same behavior as before. That is, failing the request with a clear error: 501 Method 'GET /access/acl/foobar' not implemented
Signed-off-by: Fiona Ebner <[email protected]> --- src/PVE/RESTHandler.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PVE/RESTHandler.pm b/src/PVE/RESTHandler.pm index cc82fe8..0dfb54e 100644 --- a/src/PVE/RESTHandler.pm +++ b/src/PVE/RESTHandler.pm @@ -383,8 +383,8 @@ sub map_path_to_methods { } elsif ($path_lookup->{folders}) { $path_lookup = $path_lookup->{folders}->{$comp}; $$pathmatchref .= '/' . $comp if defined($pathmatchref); - } else { - die "internal error"; + } else { # leaf endpoint + return undef; } return undef if !$path_lookup; -- 2.47.3 _______________________________________________ pve-devel mailing list [email protected] https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
