{"record":{"id":"73a1e2462c7ab3d2","repo":"juicedata/juicefs","slug":"not-exists","errorCode":null,"errorMessage":"not exists","messagePattern":"not exists","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/mem.go","lineNumber":87,"sourceCode":"\t\t},\n\t\to.owner,\n\t\to.group,\n\t\to.mode,\n\t\tfalse,\n\t}\n\treturn f, nil\n}\n\nfunc (m *memStore) Get(ctx context.Context, key string, off, limit int64, getters ...AttrGetter) (io.ReadCloser, error) {\n\tm.Lock()\n\tdefer m.Unlock()\n\t// Minimum length is 1.\n\tif key == \"\" {\n\t\treturn nil, errors.New(\"object key cannot be empty\")\n\t}\n\td, ok := m.objects[key]\n\tif !ok {\n\t\treturn nil, errors.New(\"not exists\")\n\t}\n\tif off > int64(len(d.data)) {\n\t\toff = int64(len(d.data))\n\t}\n\tdata := d.data[off:]\n\tif limit > 0 && limit < int64(len(data)) {\n\t\tdata = data[:limit]\n\t}\n\treturn io.NopCloser(bytes.NewBuffer(data)), nil\n}\n\nfunc (m *memStore) Put(ctx context.Context, key string, in io.Reader, getters ...AttrGetter) error {\n\tm.Lock()\n\tdefer m.Unlock()\n\t// Minimum length is 1.\n\tif key == \"\" {\n\t\treturn errors.New(\"object key cannot be empty\")\n\t}","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/mem.go#L69-L105","documentation":"mem.go's in-memory object store returns \"not exists\" from Get when the requested key is absent from its objects map. It is the mem-store analogue of an object-storage 404/NoSuchKey. Callers like Copy use it to detect a missing source object.","triggerScenarios":"Calling Get on a memStore with a key that was never Put, was Deleted, or whose name differs in case/spelling; Copy reading from a source key that no longer exists.","commonSituations":"Unit tests using mem as a fake store where the fixture object was never seeded; sync/copy jobs where the source key was concurrently deleted; typos or trailing-slash mismatches in keys.","solutions":["Head the key first (or check the map) before Get, or handle the not-found error explicitly","Verify the exact key string including case, prefix, and trailing '/'","Re-put the object before reading if it was expected to exist"],"exampleFix":"// before\nobj, err := store.Get(ctx, key, 0, -1)\n// after\nobj, err := store.Get(ctx, key, 0, -1)\nif err != nil && strings.Contains(err.Error(), \"not exists\") {\n\tlogger.Warnf(\"object %s missing, skipping\", key)\n\treturn nil\n}","handlingStrategy":"try-catch","validationCode":"if _, err := store.Head(ctx, key); err != nil {\n\t// key absent; skip or create\n}","typeGuard":"func isNotFound(err error) bool { return err != nil && strings.Contains(err.Error(), \"not exists\") }","tryCatchPattern":"obj, err := store.Get(ctx, key, 0, -1)\nif err != nil {\n\tif isNotFound(err) { return nil } // handle missing\n\treturn err\n}","preventionTips":["Head/check existence before Get when absence is expected","Normalize key strings (case, trailing slash) before store calls","In tests, seed every key you will read"],"tags":["object-storage","not-found","in-memory"],"backgroundTag":"resource-not-found","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"}