{"record":{"id":"eb6abcb9e9f52779","repo":"gastownhall/beads","slug":"server-newdoltserver-failed-to-determine-absolut-eb6abc","errorCode":null,"errorMessage":"server: NewDoltServer: failed to determine absolute path of rootDir","messagePattern":"server: NewDoltServer: failed to determine absolute path of rootDir","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dbproxy/server/doltserver.go","lineNumber":79,"sourceCode":"var _ DatabaseServer = (*DoltServer)(nil)\n\nfunc NewDoltServer(doltBinExec, rootDir, configPath, logFilePath string, keepAlivePeriod time.Duration, database string) (*DoltServer, error) {\n\tif doltBinExec == \"\" {\n\t\treturn nil, errors.New(\"server: NewDoltServer: doltBinExec is required\")\n\t}\n\tif rootDir == \"\" {\n\t\treturn nil, errors.New(\"server: NewDoltServer: rootDir is required\")\n\t}\n\tif configPath == \"\" {\n\t\treturn nil, errors.New(\"server: NewDoltServer: configPath is required\")\n\t}\n\tabsDoltBinExec, err := filepath.Abs(doltBinExec)\n\tif err != nil {\n\t\treturn nil, errors.New(\"server: NewDoltServer: failed to determine absolute path of doltBinExec\")\n\t}\n\tabsRootDir, err := filepath.Abs(rootDir)\n\tif err != nil {\n\t\treturn nil, errors.New(\"server: NewDoltServer: failed to determine absolute path of rootDir\")\n\t}\n\tabsConfigPath, err := filepath.Abs(configPath)\n\tif err != nil {\n\t\treturn nil, errors.New(\"server: NewDoltServer: failed to determine absolute path of configPath\")\n\t}\n\tcfg, err := servercfg.YamlConfigFromFile(filesys.LocalFS, configPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"server: NewDoltServer: parse config %q: %w\", configPath, err)\n\t}\n\tvar logFile *os.File\n\tif logFilePath != \"\" {\n\t\tabsLogFilePath, err := filepath.Abs(logFilePath)\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"server: NewDoltServer: failed to determine absolute path of logFilePath\")\n\t\t}\n\t\tlogFile, err = os.OpenFile(absLogFilePath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o600) //nolint:gosec // logFilePath is caller-derived, not user-request input\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"server: NewDoltServer: open log %q: %w\", logFilePath, err)","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dbproxy/server/doltserver.go#L61-L97","documentation":"NewDoltServer resolves rootDir (the Dolt data directory) to an absolute path with filepath.Abs so the server identity hash and child process configuration are stable regardless of cwd. This fails only when the process's current working directory cannot be determined (deleted cwd or getwd failure) and rootDir was passed as a relative path.","triggerScenarios":"Calling NewDoltServer with a relative rootDir (e.g. \".beads\") while os.Getwd() fails because the working directory was deleted or is inaccessible. An absolute rootDir bypasses this code path entirely.","commonSituations":"Daemon started in a directory later removed by tmp-cleaners or CI workspace cleanup; running inside a container whose WORKDIR was deleted; getwd failures on systems with permission issues on the cwd.","solutions":["Pass an absolute rootDir; resolve it once at startup while the cwd is still valid and reuse it","Verify the process cwd exists (readlink /proc/<pid>/cwd) — if deleted, restart the process","Recreate the deleted working directory or restart the application from an existing directory"],"exampleFix":"// before\nsrv, err := server.NewDoltServer(bin, \".beads\", cfgPath, logPath, 0, db)\n// after\nabsRoot, err := filepath.Abs(\".beads\") // resolve early, before any chdir/removal\nif err != nil { return err }\nsrv, err := server.NewDoltServer(bin, absRoot, cfgPath, logPath, 0, db)","handlingStrategy":"validation","validationCode":"root, err := filepath.Abs(rootDir)\nif err != nil { return fmt.Errorf(\"cannot resolve data dir (cwd invalid?): %w\", err) }\nif st, err := os.Stat(root); err != nil || !st.IsDir() { return fmt.Errorf(\"data dir %s missing\", root) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass absolute rootDir into NewDoltServer; derive it from a config flag resolved at startup","Verify the data directory exists before constructing the server","Restart services from a valid WorkingDirectory rather than retrying with relative paths"],"tags":["go","filesystem","server-startup","path-resolution"],"backgroundTag":"cwd-unresolvable-path","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}