{"record":{"id":"4217054590a927e6","repo":"hashicorp/nomad","slug":"file-s-not-found-in-path-s","errorCode":null,"errorMessage":"File %s not found in path %s","messagePattern":"File (.+?) not found in path (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/raftutil/state.go","lineNumber":351,"sourceCode":"\twalkFn := func(walkPath string, info os.FileInfo, err error) error {\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif filepath.Base(walkPath) == file {\n\t\t\tpath = walkPath\n\t\t}\n\t\treturn nil\n\t}\n\n\t// Walk path p looking for file\n\twalkErr := filepath.Walk(p, walkFn)\n\tif walkErr != nil {\n\t\treturn \"\", walkErr\n\t}\n\n\tif path == \"\" {\n\t\treturn \"\", fmt.Errorf(\"File %s not found in path %s\", file, p)\n\t}\n\n\treturn path, nil\n}\n","sourceCodeStart":333,"sourceCodeEnd":356,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/raftutil/state.go#L333-L356","documentation":"FindFileInPath walks the directory tree rooted at p looking for a file whose base name matches the given file name. This error is returned when the walk completed without any walk errors but the file was never encountered — the named file simply does not exist anywhere under p.","triggerScenarios":"FindFileInPath(\"raft.db\", p) (via FindRaftStore or FindRaftFile) on a directory tree that contains no file named raft.db at any depth.","commonSituations":"Pointing the recovery/inspection tooling at a WAL-backend data dir (which has wal/ but no raft.db); client-only or empty data directories; the raft.db file was deleted or moved; searching the wrong volume/backup mount.","solutions":["Use FindRaftStore instead of the raft.db-only FindRaftFile/FindFileInPath so WAL (wal/) deployments are also detected.","Confirm the path is the Nomad server data_dir containing server/raft/raft.db: ls <p>/server/raft/raft.db.","If targeting a WAL deployment, pass the wal/ directory directly (FindRaftStore accepts it).","Restore raft.db from backup or take a nomad snapshot if the file was lost.","Double-check you are searching the correct host/volume (e.g. the actual server node, not a standby with an empty dir)."],"exampleFix":"// before: only searches for raft.db, fails on WAL deployments\npath, err := raftutil.FindFileInPath(\"raft.db\", dataDir)\n// after: prefer the backend-aware search\nstorePath, err := raftutil.FindRaftStore(dataDir)","handlingStrategy":"fallback","validationCode":"// confirm a raft.db actually exists under the tree before searching\nfound := false\nfilepath.Walk(dataDir, func(p string, info os.FileInfo, err error) error {\n    if err == nil && !info.IsDir() && info.Name() == \"raft.db\" {\n        found = true\n    }\n    return nil\n})\nif !found { return errors.New(\"data dir has no raft.db; WAL backend? use FindRaftStore\") }","typeGuard":null,"tryCatchPattern":"path, err := raftutil.FindFileInPath(\"raft.db\", dataDir)\nif err != nil {\n    if strings.Contains(err.Error(), \"not found in path\") {\n        // fall back to backend-aware search (handles wal/ too)\n        return raftutil.FindRaftStore(dataDir)\n    }\n    return err\n}","preventionTips":["Prefer FindRaftStore over FindFileInPath/FindRaftFile for WAL support.","Verify the server data dir layout before running searches.","Check you are on the right host/volume/backup mount.","Confirm the file wasn't removed by cleanup scripts."],"tags":["raft","filesystem","paths","not-found"],"backgroundTag":"file-not-found","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}