{"record":{"id":"2265824b908b127a","repo":"juicedata/juicefs","slug":"the-result-for-list-is-incorrect","errorCode":null,"errorMessage":"the result for list is incorrect","messagePattern":"the result for list is incorrect","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/objbench.go","lineNumber":969,"sourceCode":"\t\t\tk := fmt.Sprintf(\"hashKey%d\", i)\n\t\t\tsortedKeys = append(sortedKeys, k)\n\t\t\tif err := blob.Put(ctx, fmt.Sprintf(\"hashKey%d\", i), bytes.NewReader(br)); err != nil {\n\t\t\t\treturn fmt.Errorf(\"put object failed: %s\", err.Error())\n\t\t\t}\n\t\t}\n\t\tsort.Strings(sortedKeys)\n\t\tdefer func() {\n\t\t\tfor i := 0; i < keyTotal; i++ {\n\t\t\t\t_ = blob.Delete(ctx, fmt.Sprintf(\"hashKey%d\", i))\n\t\t\t}\n\t\t}()\n\n\t\tif objs, err := listAll(ctx, blob, \"hashKey\", \"\", int64(keyTotal)); err != nil {\n\t\t\treturn fmt.Errorf(\"list failed: %s\", err)\n\t\t} else {\n\t\t\tfor i := 0; i < keyTotal; i++ {\n\t\t\t\tif objs[i].Key() != sortedKeys[i] {\n\t\t\t\t\treturn fmt.Errorf(\"the result for list is incorrect\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n\n\trunCase(\"special key\", func(blob object.ObjectStorage) error {\n\t\tkey := \"测试编码文件\" + `{\"name\":\"juicefs\"}` + string('\\u001F') + \"%uFF081%uFF09.jpg\"\n\t\tdefer blob.Delete(ctx, key) //nolint:errcheck\n\t\tif err := blob.Put(ctx, key, bytes.NewReader([]byte(\"1\"))); err != nil {\n\t\t\treturn fmt.Errorf(\"put encode file failed: %s\", err)\n\t\t} else {\n\t\t\tif resp, _, _, err := blob.List(ctx, \"\", \"测试编码文件\", \"\", \"\", 1, true); err != nil && err != utils.ErrNotSUP {\n\t\t\t\treturn fmt.Errorf(\"list encode file failed %s\", err)\n\t\t\t} else if len(resp) == 1 && resp[0].Key() != key {\n\t\t\t\treturn fmt.Errorf(\"list encode file failed: expect key %s, but got %s\", key, resp[0].Key())\n\t\t\t}\n\t\t}","sourceCodeStart":951,"sourceCodeEnd":987,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/objbench.go#L951-L987","documentation":"After listing the hashKey* objects, objbench compares returned keys against the lexicographically sorted key slice and reports this plain message when they differ. It means the backend's List did not return keys in lexicographic order or missed/duplicated keys.","triggerScenarios":"`objs[i].Key() != sortedKeys[i]` during the objbench sorting test — the backend returns out-of-order, missing, or extra keys for prefix 'hashKey'.","commonSituations":"Custom or buggy object storage implementations that don't sort List results lexicographically; backends with non-standard key encodings; concurrent writers adding hashKey-like keys mid-test.","solutions":["Fix or upgrade the object storage implementation so List returns keys in lexicographic order","Run objbench against a different backend to isolate whether the driver is at fault","Ensure no concurrent writers touch the same prefix during the benchmark"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"keys := make([]string, len(objs))\nfor i, o := range objs { keys[i] = o.Key() }\nif !sort.StringsAreSorted(keys) { /* backend list ordering broken */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Test custom object-storage drivers with objbench before production use","Never rely on unsorted List output; sort client-side if unsure","Ensure no concurrent writers during ordering tests"],"tags":["object-storage","list","ordering"],"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"}