Skip to content

Commit

Permalink
Add error logs for unsupported directories (#2683)
Browse files Browse the repository at this point in the history
Prints out error logs when ListObjects return objects which are unsupported i.e. objects with names "", or starting with `/` or containing `//` .
  • Loading branch information
gargnitingoogle authored Nov 12, 2024
1 parent ba65fa9 commit 5ae03ff
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/fs/inode/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/googlecloudplatform/gcsfuse/v2/internal/cache/metadata"
"github.com/googlecloudplatform/gcsfuse/v2/internal/gcsx"
"github.com/googlecloudplatform/gcsfuse/v2/internal/locker"
"github.com/googlecloudplatform/gcsfuse/v2/internal/logger"
"github.com/googlecloudplatform/gcsfuse/v2/internal/storage/gcs"
"github.com/googlecloudplatform/gcsfuse/v2/internal/storage/storageutil"
"github.com/jacobsa/fuse/fuseops"
Expand Down Expand Up @@ -732,8 +733,12 @@ func (d *dirInode) readObjects(
}

// Add implicit directories into the result.
unsupportedPrefixes := []string{}
for _, p := range listing.CollapsedRuns {
pathBase := path.Base(p)
if storageutil.IsUnsupportedObjectName(p) {
unsupportedPrefixes = append(unsupportedPrefixes, p)
}
dirName := NewDirName(d.Name(), pathBase)
if d.isBucketHierarchical() {
folder := gcs.Folder{Name: dirName.objectName}
Expand All @@ -757,6 +762,9 @@ func (d *dirInode) readObjects(
cores[dirName] = implicitDir
}
}
if len(unsupportedPrefixes) > 0 {
logger.Warnf("Encountered unsupported prefixes during listing: %v", unsupportedPrefixes)
}
return
}

Expand Down

0 comments on commit 5ae03ff

Please sign in to comment.