From 9d08c155c0737fd49fc00191e93c0cd8964ca05e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 18 Nov 2024 17:36:58 +0100 Subject: [PATCH] prevent panic when logging error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/prevent-panic.md | 5 +++++ pkg/storage/utils/decomposedfs/lookup/lookup.go | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/prevent-panic.md diff --git a/changelog/unreleased/prevent-panic.md b/changelog/unreleased/prevent-panic.md new file mode 100644 index 0000000000..710d55d613 --- /dev/null +++ b/changelog/unreleased/prevent-panic.md @@ -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 diff --git a/pkg/storage/utils/decomposedfs/lookup/lookup.go b/pkg/storage/utils/decomposedfs/lookup/lookup.go index fc95764aaf..2a4671cda7 100644 --- a/pkg/storage/utils/decomposedfs/lookup/lookup.go +++ b/pkg/storage/utils/decomposedfs/lookup/lookup.go @@ -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 }