{"record":{"id":"aae7d6c9073f1804","repo":"hashicorp/nomad","slug":"failed-to-find-raft-store-in-v-v","errorCode":null,"errorMessage":"failed to find raft store in %v: %v","messagePattern":"failed to find raft store in (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/raftutil/fsm.go","lineNumber":49,"sourceCode":"\n\tlogger hclog.Logger\n\n\t// nomad state\n\tstore RaftStore\n\tfsm   nomadFSM\n\tsnaps *raft.FileSnapshotStore\n\n\t// raft\n\tlogFirstIdx uint64\n\tlogLastIdx  uint64\n\tnextIdx     uint64\n}\n\nfunc NewFSM(p string) (*FSMHelper, error) {\n\t// Auto-detect the backend: look for wal/ directory first, then raft.db.\n\tstorePath, err := FindRaftStore(p)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to find raft store in %v: %v\", p, err)\n\t}\n\n\tstore, firstIdx, lastIdx, err := RaftStateInfo(storePath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open raft store %v: %v\", storePath, err)\n\t}\n\n\tlogger := hclog.L()\n\n\tsnaps, err := raft.NewFileSnapshotStoreWithLogger(p, 1000, logger)\n\tif err != nil {\n\t\tstore.Close()\n\t\treturn nil, fmt.Errorf(\"failed to open snapshot dir: %v\", err)\n\t}\n\n\tfsm, err := dummyFSM(logger)\n\tif err != nil {\n\t\tstore.Close()","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/raftutil/fsm.go#L31-L67","documentation":"NewFSM wraps the error from FindRaftStore when it cannot locate a valid Raft backend (wal/ directory or raft.db file) under the given data path. The data directory either has no recognizable Raft store or is unreadable.","triggerScenarios":"Calling NewFSM with a path that is not a Nomad server data dir, an empty directory, a client data dir (no raft state), or a path with wrong permissions that prevents detection of wal/ or raft.db.","commonSituations":"Pointing raftutil tooling at a Nomad client directory instead of a server data dir; running as a user without read access to /var/nomad/data; pointing at a fresh data dir that was never bootstrapped.","solutions":["Verify the path is a Nomad SERVER data dir containing raft.db or a wal/ subdirectory","Check filesystem permissions on the data dir (read/execute for the running user)","Confirm the server has been initialized/bootstrapped (fresh dirs have no raft store)"],"exampleFix":"// before\nfsm, err := raftutil.NewFSM(dataDir)\n// after\nif _, err := os.Stat(filepath.Join(dataDir, \"raft.db\")); os.IsNotExist(err) {\n    if _, err := os.Stat(filepath.Join(dataDir, \"wal\")); os.IsNotExist(err) {\n        return nil, fmt.Errorf(\"%s is not a server data dir: no raft.db or wal/\", dataDir)\n    }\n}\nfsm, err := raftutil.NewFSM(dataDir)","handlingStrategy":"validation","validationCode":"func hasRaftStore(dataDir string) error {\n    for _, p := range []string{\"raft.db\", \"wal\"} {\n        if fi, err := os.Stat(filepath.Join(dataDir, p)); err == nil && !fi.IsDir() || fi != nil && fi.IsDir() {\n            return nil\n        }\n    }\n    return fmt.Errorf(\"%s has no raft.db or wal/ — not a server data dir\", dataDir)\n}","typeGuard":null,"tryCatchPattern":"if err := raftutil.NewFSM(dataDir); err != nil {\n    if strings.Contains(err.Error(), \"failed to find raft store\") {\n        return fmt.Errorf(\"path %q is not a Nomad server data dir: %w\", dataDir, err)\n    }\n    return err\n}","preventionTips":["Confirm the path is a server (not client) data dir before invoking NewFSM","Check read/execute permissions on the data dir for the running user","Require a bootstrapped data dir; fresh dirs have no raft store"],"tags":["raft","storage","filesystem","go"],"backgroundTag":"raft-store-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"}