19428: Fix failing request on normal failed user lookup case.
authorTom Clegg <tom@curii.com>
Tue, 20 Sep 2022 17:44:12 +0000 (13:44 -0400)
committerTom Clegg <tom@curii.com>
Tue, 20 Sep 2022 17:44:12 +0000 (13:44 -0400)
refs #19428

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

services/keep-web/handler.go

index b04add1c494eca08a46c6ea542d5b23448c687e4..0c75ac56cfc4d69d5845ec332196942d5998cdf7 100644 (file)
@@ -6,6 +6,7 @@ package keepweb
 
 import (
        "encoding/json"
+       "errors"
        "fmt"
        "html"
        "html/template"
@@ -490,7 +491,11 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
                http.Error(w, "session cache: "+err.Error(), http.StatusInternalServerError)
        }
        tokenUser, err = h.Cache.GetTokenUser(arv.ApiToken)
-       if err != nil {
+       if e := (interface{ HTTPStatus() int })(nil); errors.As(err, &e) && e.HTTPStatus() == http.StatusForbidden {
+               // Ignore expected error looking up user record when
+               // using a scoped token that allows getting
+               // collections/X but not users/current
+       } else if err != nil {
                http.Error(w, "user lookup: "+err.Error(), http.StatusInternalServerError)
        }