Repository navigation
Description
Summary
ListObjects issues a single ListObjectsV2 call and never follows the continuation token. S3 caps a page at 1000 keys, and Readdir requests exactly 1000 — so any directory with more than 1000 entries is silently truncated with no error and no warning. Files that exist are invisible to ls, to find, and to any tool that walks the tree.
Background
ListObjects (internal/storage/s3/backend.go) makes one request and returns what came back. Grep for IsTruncated, NextContinuationToken, and NextMarker across internal/storage/s3/backend.go returns zero hits — there is no pagination loop anywhere in the backend.
The caller sits exactly at the cap:
objects, err := n.fs.backend.ListObjects(ctx, prefix, 1000) // List up to 1000 objects(internal/fuse/filesystem.go:258)
Requesting 1000 against a 1000-key page limit means the truncation point and the request limit coincide, so the shortfall is indistinguishable from a directory that genuinely has 1000 entries. For research-computing workloads — the stated target for this project — directories of tens of thousands of files are routine, so this is not an edge case.
Second-order consequence for v0.14.0. Rmdir needs an emptiness check, and #163 specifies ListObjects for it. An unpaginated list cannot answer "is this prefix empty" reliably for large prefixes. Fixing pagination here removes a correctness hazard from that work before it starts. The Lookup fallback path (filesystem.go:232) calls ListObjects(ctx, childPath+"/", 1) to test directory existence — that one is correct, since it only needs to know whether at least one key exists.
Implementation
-
Loop on
IsTruncated, threadingContinuationTokenfromNextContinuationToken, accumulating until either the requestedmaxKeysis satisfied or S3 reports no more pages. Preserve the existingmaxKeyscontract: a caller asking for 1 must still cause exactly one request withMaxKeys: 1and no follow-up. -
Treat
maxKeys <= 0as "all keys" and page to exhaustion. Confirm which callers rely on the current semantics before changing the sentinel — audit everyListObjectscall site, not just the two ininternal/fuse/filesystem.go. -
Guard against unbounded memory on a huge prefix. A million-key directory should not be accumulated into one slice silently. Either cap with an explicit error, or add a streaming/callback variant for the walk-everything case and leave the slice-returning form for bounded requests.
-
In
Readdir, stop passing a magic 1000. Pass 0 (all) if the streaming form is used, or a configurable limit with aWARNlog when the limit is hit, so truncation is at least observable rather than silent.
Acceptance Criteria
-
Unit test with a mocked paginated response: two pages,
IsTruncated: trueon the first, and the returned slice contains keys from both pages. -
Unit test:
ListObjects(ctx, prefix, 1)issues exactly one request and returns one key — no regression in theLookupexistence-check path. -
Integration test creating 1500 objects under one prefix, then asserting
ListObjectsreturns all 1500:AWS_PROFILE=aws AWS_REGION=us-west-2 go test -race -tags=integration ./internal/storage/s3/... -
Live mount: a directory with 1500 files reports 1500 from
ls -1 /mnt/objectfs/test/big | wc -l. -
go test -race ./internal/storage/s3/... ./internal/fuse/...passes; package coverage stays at or above 80%.
Dependencies
None. Should land before #163 (Unlink/Rmdir), whose emptiness check depends on a reliable listing.
Activity