fix (unified-storage): Fix error when trying to get parents of folder as a viewer (#101245)

* Fix error when trying to get parents of folder as a viewer with unified-storage enabled
This commit is contained in:
Will Assis
2025-02-25 14:38:32 +02:00
committed by GitHub
parent ce8a874bf0
commit 1a65154e74
2 changed files with 95 additions and 0 deletions
@@ -2,7 +2,9 @@ package folderimpl
import (
"context"
"errors"
"fmt"
"net/http"
"strings"
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -144,6 +146,12 @@ func (ss *FolderUnifiedStoreImpl) GetParents(ctx context.Context, q folder.GetPa
for parentUid != "" {
out, err := ss.k8sclient.Get(ctx, parentUid, q.OrgID, v1.GetOptions{})
if err != nil {
var statusError *apierrors.StatusError
if errors.As(err, &statusError) && statusError.ErrStatus.Code == http.StatusForbidden {
// If we get a Forbidden error when requesting the parent folder, it means the user does not have access
// to it, nor its parents. So we can stop looping
break
}
return nil, err
}