juicedata/juicefs · error

list should not return anything, but got %d

Error message

list should not return anything, but got %d

What it means

In the filesystem branch of objbench's "list objects" case, a LIST with prefix "test2" (which was never created) must return zero objects. This message means the backend returned a non-empty list for a prefix that has no keys, i.e. prefix filtering is broken or leftover keys from a previous run exist.

Source

Thrown at cmd/objbench.go:919

				if objs[1].Key() != key {
					return fmt.Errorf("first key should be test, but got %s", objs[1].Key())
				}
				if objs[1].Size() != 5 {
					return fmt.Errorf("size of first key shold be 5, but got %v", objs[1].Size())
				}
				now := time.Now()
				if objs[1].Mtime().Before(now.Add(-30*time.Second)) || objs[1].Mtime().After(now.Add(time.Second*30)) {
					return fmt.Errorf("mtime of key should be within 30 seconds, but got %s", objs[1].Mtime().Sub(now))
				}
			} else {
				return fmt.Errorf("list failed: %s", err)
			}

			objs, err = listAll(ctx, blob, "", "test2", 1)
			if err != nil {
				return fmt.Errorf("list failed: %s", err)
			} else if len(objs) != 0 {
				return fmt.Errorf("list should not return anything, but got %d", len(objs))
			}
		} else {
			objs, err2 := listAll(ctx, blob, "", "", 1)
			if err2 == nil {
				if len(objs) != 1 {
					return fmt.Errorf("list should return 1 keys, but got %d", len(objs))
				}
				if objs[0].Key() != key {
					return fmt.Errorf("first key should be test, but got %s", objs[0].Key())
				}
				if objs[0].Size() != 5 {
					return fmt.Errorf("size of first key shold be 5, but got %v", objs[0].Size())
				}
				now := time.Now()
				if objs[0].Mtime().Before(now.Add(-30*time.Second)) || objs[0].Mtime().After(now.Add(time.Second*30)) {
					return fmt.Errorf("mtime of key should be within 30 seconds, but got %s", objs[0].Mtime().Sub(now))
				}
			} else {

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Clean the bucket/prefix of leftovers from prior objbench runs before testing.
  2. Fix the backend's List to apply the prefix filter correctly.
  3. Use a dedicated, empty bucket for objbench to avoid collisions.
  4. Re-run objbench after cleanup to confirm the empty-prefix list behavior.

Example fix

// before: ignoring prefix
if strings.HasPrefix(k, prefix) || prefix == "" {...}
// after: always filter
if strings.HasPrefix(k, prefix) {...}
Defensive patterns

Strategy: validation

Validate before calling

objs, err := listAll(ctx, blob, "", "test2", 1)
if err == nil && len(objs) != 0 {
    return fmt.Errorf("stale keys under test2; clean the bucket first")
}

Prevention

When it happens

Trigger: `juicefs objbench` on a filesystem backend that ignores the "test2" prefix and returns all keys; or a polluted bucket where keys starting with "test2" already exist from earlier runs.

Common situations: Custom object storage whose List does not honor prefix; running objbench twice without cleanup in a shared bucket; keys colliding with the bench's naming.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/2fca79e0cfc8ed40. Report an issue: GitHub.