@@ -1194,20 +1194,25 @@ func (s *Server) Query(ctx context.Context, req *api.Request) (*api.Response, er
11941194
11951195// Query handles queries or mutations
11961196func (s * Server ) QueryNoGrpc (ctx context.Context , req * api.Request ) (* api.Response , error ) {
1197- // if the `namespace-str` is present in the metadata, use it to attach the namespace
1197+ // If the `namespace-str` is present in the metadata, use it to attach the namespace
11981198 // otherwise, use the namespace from the JWT.
1199- nsStr , err := x .ExtractNamespaceStr (ctx )
1200- if err == nil {
1199+ var attached bool
1200+ nsStr , _ := x .ExtractNamespaceStr (ctx )
1201+ if nsStr != "" {
12011202 ns , err := getNamespaceIDFromName (x .AttachNamespace (ctx , x .RootNamespace ), nsStr )
12021203 if err == nil {
12031204 ctx = x .AttachNamespace (ctx , ns )
1205+ attached = true
12041206 } else {
1205- ctx = x .AttachJWTNamespace (ctx )
1207+ if ! errors .Is (err , x .ErrNamespaceNotFound ) {
1208+ glog .Warningf ("Error getting namespace ID from name: %v. Defaulting to default or JWT namespace" , err )
1209+ }
12061210 }
1207- } else {
1211+ }
1212+ if ! attached {
12081213 ctx = x .AttachJWTNamespace (ctx )
12091214 }
1210- // if acl is enabled, then the namespace from the JWT will be applied in the test below
1215+ // If acl is enabled, then the namespace from the JWT will be applied in the test below
12111216 // overriding any namespace from the metadata obtained from the `namespace-str` above.
12121217 if x .WorkerConfig .AclEnabled && req .GetStartTs () != 0 {
12131218 // A fresh StartTs is assigned if it is 0.
0 commit comments