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 <[email protected]>
  • 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.