{"record":{"id":"955aa2f6ef5df021","repo":"juicedata/juicefs","slug":"first-key-should-be-test-but-got-s","errorCode":null,"errorMessage":"first key should be test, but got %s","messagePattern":"first key should be test, but got (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/objbench.go","lineNumber":902,"sourceCode":"\t\tbr := []byte(\"hello\")\n\t\tif err := blob.Put(ctx, key, bytes.NewReader(br)); err != nil {\n\t\t\treturn fmt.Errorf(\"put object failed: %s\", err)\n\t\t}\n\t\tdefer blob.Delete(ctx, key) //nolint:errcheck\n\t\tif isFileSystem {\n\t\t\tobjs, err := listAll(ctx, blob, \"\", \"\", 2)\n\t\t\tif err == nil {\n\t\t\t\tif len(objs) != 2 {\n\t\t\t\t\treturn fmt.Errorf(\"list should return 2 keys, but got %d\", len(objs))\n\t\t\t\t}\n\t\t\t\tif objs[0].Key() != \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"first key should be empty string, but got %s\", objs[0].Key())\n\t\t\t\t}\n\t\t\t\tif objs[0].Size() != 0 {\n\t\t\t\t\treturn fmt.Errorf(\"first object size should be 0, but got %d\", objs[0].Size())\n\t\t\t\t}\n\t\t\t\tif objs[1].Key() != key {\n\t\t\t\t\treturn fmt.Errorf(\"first key should be test, but got %s\", objs[1].Key())\n\t\t\t\t}\n\t\t\t\tif objs[1].Size() != 5 {\n\t\t\t\t\treturn fmt.Errorf(\"size of first key shold be 5, but got %v\", objs[1].Size())\n\t\t\t\t}\n\t\t\t\tnow := time.Now()\n\t\t\t\tif objs[1].Mtime().Before(now.Add(-30*time.Second)) || objs[1].Mtime().After(now.Add(time.Second*30)) {\n\t\t\t\t\treturn fmt.Errorf(\"mtime of key should be within 30 seconds, but got %s\", objs[1].Mtime().Sub(now))\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"list failed: %s\", err)\n\t\t\t}\n\n\t\t\tobjs, err = listAll(ctx, blob, \"\", \"test2\", 1)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"list failed: %s\", err)\n\t\t\t} else if len(objs) != 0 {\n\t\t\t\treturn fmt.Errorf(\"list should not return anything, but got %d\", len(objs))\n\t\t\t}","sourceCodeStart":884,"sourceCodeEnd":920,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/objbench.go#L884-L920","documentation":"Raised in the objbench 'list objects' filesystem case: the second listed entry must be the test object under `key` ('test'), but a different key was returned. The message text says 'first key' but actually checks objs[1] — the key that objbench just Put. This validates that the list returns the newly written object in the expected position.","triggerScenarios":"listAll(ctx, blob, \"\", \"\", 2) returned 2 entries whose first is \"\" but whose second entry's Key() != key — caused by leftover objects in the test prefix, incorrect ordering, or the backend returning a differently-normalized key (e.g. leading slash).","commonSituations":"Dirty test directory containing other files that shift entry positions; backend key normalization adding/removing separators; backend sorting that misplaces the new object; stale caches in a custom implementation.","solutions":["Remove leftover files/keys from the test directory/prefix and rerun.","Check how the backend normalizes keys in List vs Put (trailing/leading slashes).","Verify ordering matches the reference file:// implementation.","Clear any entry caches on filesystem-backed stores before rerunning.","Upgrade/align JuiceFS versions if backend and CLI differ."],"exampleFix":"// before: backend returns key \"/test\" for put key \"test\"\nreturn &entry{key: \"/\" + rel, ...}\n// after: keep keys consistent with Put\nreturn &entry{key: rel, ...}","handlingStrategy":"validation","validationCode":"// ensure the test key exists and prefix is clean before listing\nobjs, _ := listAll(ctx, blob, \"\", \"\", 10)\nkeys := make([]string, 0, len(objs))\nfor _, o := range objs { keys = append(keys, o.Key()) }\n// expect keys == [\"\", key]","typeGuard":null,"tryCatchPattern":"if objs[1].Key() != key {\n    log.Printf(\"got %q, want %q; check key normalization and leftovers\", objs[1].Key(), key)\n}","preventionTips":["Use unique keys/prefixes per run to avoid leftovers.","Normalize keys (no leading slashes) consistently.","Match ordering behavior of the reference file backend.","Clean the benchmark directory before runs."],"tags":["object-storage","list","key-mismatch","filesystem"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}