18896: add locking. Also handle v1 tokens shorter than 5 characters.
[arvados.git] / lib / controller / router / router.go
index e42d9a555b5993e00e2a7ce3eff29ab174ab0b44..05bdb4754f0a860ac552867d42bf6e30af9eb4d6 100644 (file)
@@ -597,7 +597,11 @@ func (rtr *router) addRoute(endpoint arvados.APIEndpoint, defaultOpts func() int
                                        tokenUUIDs = append(tokenUUIDs, tokenParts[1])
                                }
                        } else {
-                               tokenUUIDs = append(tokenUUIDs, "v1 token ending in "+t[len(t)-5:])
+                               end := t
+                               if len(t) > 5 {
+                                       end = t[len(t)-5:]
+                               }
+                               tokenUUIDs = append(tokenUUIDs, "v1 token ending in "+end)
                        }
                }
                httpserver.SetResponseLogFields(req.Context(), logrus.Fields{"tokenUUIDs": tokenUUIDs})