{"record":{"id":"bc12df6b46aaf1e2","repo":"AlistGo/alist","slug":"object-not-found","errorCode":null,"errorMessage":"object not found","messagePattern":"object not found","errorType":"exception","errorClass":"ObjectNotFound","httpStatus":null,"severity":"error","filePath":"internal/errs/object.go","lineNumber":10,"sourceCode":"package errs\n\nimport (\n\t\"errors\"\n\n\tpkgerr \"github.com/pkg/errors\"\n)\n\nvar (\n\tObjectNotFound = errors.New(\"object not found\")\n\tNotFolder      = errors.New(\"not a folder\")\n\tNotFile        = errors.New(\"not a file\")\n)\n\nfunc IsObjectNotFound(err error) bool {\n\treturn errors.Is(pkgerr.Cause(err), ObjectNotFound)\n}\n","sourceCodeStart":1,"sourceCodeEnd":18,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/internal/errs/object.go#L1-L18","documentation":"ObjectNotFound is the storage-driver-level 'file or folder does not exist' sentinel, defined in internal/errs/object.go. Unlike MetaNotFound (cache miss in the op layer), it is returned when the backing storage itself reports the object is absent. errs.IsObjectNotFound and errs.IsNotFoundError unwrap with pkg/errors Cause and test against it.","triggerScenarios":"A storage driver's List/Get hitting a missing key (S3 NoSuchKey, 404 from WebDAV/FTP panels) that the driver translates to ObjectNotFound; direct driver calls on paths deleted remotely; ops after a remote deletion not yet reflected in the meta cache.","commonSituations":"Files deleted upstream while still cached in AList; stale share links; eventual-consistency object stores where a write is listed before it is readable; users pasting old URLs. Standard remedy is to treat as 404 and invalidate the cached entry.","solutions":["Confirm the object exists in the underlying storage (provider console)","Clear/invalidate the meta cache for the parent path so AList re-lists from the source","Return or map to a 404 response using errs.IsObjectNotFound(err) instead of surfacing a 500","If the object was renamed/moved remotely, refresh the directory listing"],"exampleFix":"// before\nif err != nil { common.ErrorResp(c, err, 500) }\n\n// after\nif errs.IsObjectNotFound(err) {\n    common.ErrorResp(c, err, 404)\n} else if err != nil {\n    common.ErrorResp(c, err, 500)\n}","handlingStrategy":"try-catch","validationCode":"// optional pre-check via meta cache (cheap) before driver calls\nif _, err := op.Get(ctx, path); errs.IsObjectNotFound(err) {\n    op.InvalidateCache(parentDir) // refresh and re-check once\n}","typeGuard":"func isObjectNotFound(err error) bool {\n    return errs.IsObjectNotFound(err)\n}","tryCatchPattern":"obj, err := storage.Get(ctx, path)\nif err != nil {\n    if isObjectNotFound(err) { return nil, errs.NewErr(errs.ObjectNotFound, \"%s missing\", path) }\n    return nil, err\n}","preventionTips":["Map this sentinel to HTTP 404 in handlers","Invalidate the parent's cache after remote deletions","For eventual-consistency stores, add a short read-retry window","Avoid caching negative lookups longer than necessary"],"tags":["filesystem","driver","not-found"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}