Skip to content

Commit

Permalink
Merge pull request #4954 from butonic/prevent-panic
Browse files Browse the repository at this point in the history
prevent panic when logging error
  • Loading branch information
micbar authored Nov 19, 2024
2 parents 1373e6e + 9d08c15 commit d341028
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 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
7 changes: 5 additions & 2 deletions pkg/storage/utils/decomposedfs/lookup/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,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 d341028

Please sign in to comment.