diff --git a/changelog/28669.txt b/changelog/28669.txt new file mode 100644 index 0000000000..e2594052ed --- /dev/null +++ b/changelog/28669.txt @@ -0,0 +1,3 @@ +```release-note:bug +core: Fixed panic seen when performing help requests without /v1/ in the URL. +``` diff --git a/http/handler.go b/http/handler.go index ceaaf34b45..c74f392aee 100644 --- a/http/handler.go +++ b/http/handler.go @@ -1417,7 +1417,13 @@ func respondOIDCPermissionDenied(w http.ResponseWriter) { enc.Encode(oidcResponse) } -// trimPath removes the /v1/ prefix and the namespace from the path +// trimPath removes the /v1/ prefix (if present) and the namespace from the path func trimPath(ns *namespace.Namespace, path string) string { - return ns.TrimmedPath(path[len("/v1/"):]) + const v1Prefix = "/v1/" + + if strings.HasPrefix(path, v1Prefix) { + return ns.TrimmedPath(path[len(v1Prefix):]) + } + + return ns.TrimmedPath(path) }