{"record":{"id":"e2f772897d85877d","repo":"kopia/kopia","slug":"entry-not-found-q","errorCode":null,"errorMessage":"entry not found: %q","messagePattern":"entry not found: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"snapshot/snapshotfs/objref.go","lineNumber":55,"sourceCode":"\tcurrent := startingDir\n\n\tfor _, part := range pathElements {\n\t\tif part == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tdir, ok := current.(fs.Directory)\n\t\tif !ok {\n\t\t\treturn nil, errors.Errorf(\"entry not found %q: parent is not a directory\", part)\n\t\t}\n\n\t\te, err := dir.Child(ctx, part)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"error reading directory\")\n\t\t}\n\n\t\tif e == nil {\n\t\t\treturn nil, errors.Errorf(\"entry not found: %q\", part)\n\t\t}\n\n\t\tcurrent = e\n\t}\n\n\treturn current, nil\n}\n\nfunc parseNestedObjectID(ctx context.Context, startingDir fs.Entry, parts []string) (object.ID, error) {\n\te, err := GetNestedEntry(ctx, startingDir, parts)\n\tif err != nil {\n\t\treturn object.EmptyID, err\n\t}\n\n\thoid, ok := e.(object.HasObjectID)\n\tif !ok {\n\t\treturn object.EmptyID, errors.New(\"entry without ObjectID\")\n\t}","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/snapshot/snapshotfs/objref.go#L37-L73","documentation":"After a successful Child lookup, GetNestedEntry checks whether the returned entry is nil. Kopia's Directory.Child contract returns nil (not an error) when the named child does not exist, so this code converts that nil result into an explicit 'entry not found' error naming the missing component.","triggerScenarios":"Calling GetNestedEntry / FilesystemEntryFromIDWithPath with a path whose final component does not exist in the parent directory — e.g. 'snapshotID/etc/passwd-does-not-exist'.","commonSituations":"Typos in restored file paths; paths referencing files deleted between snapshots; automation assuming a path exists in every snapshot; case-sensitivity mismatches.","solutions":["Verify the exact path exists in the snapshot ('kopia ls <snapshotID>/path').","Check spelling and case of the path component.","List the parent directory to find the correct entry name.","Handle nil-entry semantics in calling code if you expect missing paths."],"exampleFix":"// before\ne, err := snapshotfs.FilesystemEntryFromIDWithPath(ctx, rep, sid+\"/etc/passwd\")\n// after\nif _, err := snapshotfs.FilesystemEntryFromIDWithPath(ctx, rep, sid+\"/etc/passwd\"); err != nil {\n    // fall back or report missing path\n    return handleMissing()\n}","handlingStrategy":"validation","validationCode":"parent, err := snapshotfs.FilesystemEntryFromIDWithPath(ctx, rep, sid+\"/etc\")\nif err != nil { return err }\ndir, ok := parent.(fs.Directory)\nif !ok { return errors.New(\"parent not a directory\") }\nif _, err := dir.Child(ctx, \"passwd\"); err != nil {\n    return fmt.Errorf(\"entry missing in snapshot\")\n}","typeGuard":null,"tryCatchPattern":"entry, err := snapshotfs.GetNestedEntry(ctx, root, parts)\nif err != nil && strings.Contains(err.Error(), \"entry not found\") {\n    return handleMissingPath(parts) // e.g. skip, list parent, or report\n}","preventionTips":["List the parent directory to confirm entry names before lookup","Mind case sensitivity of paths","Remember snapshots reflect state at capture time — files may not exist in every snapshot","Handle nil-returning Child lookups defensively when paths are optional"],"tags":["not-found","path","filesystem"],"backgroundTag":"resource-not-found","analyzedSha":"82495e54b584c1ef6073c9e1be048f57f8aef078","analyzedAt":"2026-09-07T20:35:21.689Z","contentChangedAt":"2026-09-07T20:35:21.689Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}