Skip to content

Commit 03f7487

Browse files
Add log output if error from getting workspace by name is something other than "not found"
1 parent 7de42f6 commit 03f7487

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

edgraph/namespace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func getNamespaceIDFromName(ctx context.Context, nsName string) (uint64, error)
310310
return 0, err
311311
}
312312
if len(data.Namespaces) == 0 {
313-
return 0, errors.Errorf("namespace %q not found", nsName)
313+
return 0, errors.Wrapf(x.ErrNamespaceNotFound, "namespace %q not found", nsName)
314314
}
315315

316316
glog.Infof("Found namespace [%v] with id [%d]", nsName, data.Namespaces[0].ID)

edgraph/server.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,20 +1194,25 @@ func (s *Server) Query(ctx context.Context, req *api.Request) (*api.Response, er
11941194

11951195
// Query handles queries or mutations
11961196
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
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

Comments
 (0)