@@ -1194,20 +1194,25 @@ func (s *Server) Query(ctx context.Context, req *api.Request) (*api.Response, er
1194
1194
1195
1195
// Query handles queries or mutations
1196
1196
func (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
1198
1198
// 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 != "" {
1201
1202
ns , err := getNamespaceIDFromName (x .AttachNamespace (ctx , x .RootNamespace ), nsStr )
1202
1203
if err == nil {
1203
1204
ctx = x .AttachNamespace (ctx , ns )
1205
+ attached = true
1204
1206
} 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
+ }
1206
1210
}
1207
- } else {
1211
+ }
1212
+ if ! attached {
1208
1213
ctx = x .AttachJWTNamespace (ctx )
1209
1214
}
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
1211
1216
// overriding any namespace from the metadata obtained from the `namespace-str` above.
1212
1217
if x .WorkerConfig .AclEnabled && req .GetStartTs () != 0 {
1213
1218
// A fresh StartTs is assigned if it is 0.
0 commit comments