Skip to content

Commit

Permalink
prevent panic when logging error
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Nov 18, 2024
1 parent 4ce61d4 commit 40c709d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/prevent-panic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: prevent a panic when logging an error

We fixed a panic when constructing a path failed to get the parent for a node.

https://github.com/cs3org/reva/pull/4954
18 changes: 11 additions & 7 deletions pkg/storage/utils/decomposedfs/lookup/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ import (

user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/rogpeppe/go-internal/lockedfile"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"

"github.com/cs3org/reva/v2/pkg/appctx"
"github.com/cs3org/reva/v2/pkg/errtypes"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/metadata"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/metadata/prefixes"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/node"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/options"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/rogpeppe/go-internal/lockedfile"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"
)

var tracer trace.Tracer
Expand Down Expand Up @@ -235,14 +236,17 @@ func (lu *Lookup) GenerateSpaceID(spaceType string, owner *user.User) (string, e
// Path returns the path for node
func (lu *Lookup) Path(ctx context.Context, n *node.Node, hasPermission node.PermissionFunc) (p string, err error) {
root := n.SpaceRoot
var child *node.Node
for n.ID != root.ID {
p = filepath.Join(n.Name, p)
child = n
if n, err = n.Parent(ctx); err != nil {
appctx.GetLogger(ctx).
Error().Err(err).
Str("path", p).
Str("spaceid", n.SpaceID).
Str("nodeid", n.ID).
Str("spaceid", child.SpaceID).
Str("nodeid", child.ID).
Str("parentid", child.ParentID).
Msg("Path()")
return
}
Expand Down

0 comments on commit 40c709d

Please sign in to comment.