{"record":{"id":"6e0db2972ce9e817","repo":"gastownhall/beads","slug":"server-newdoltserver-failed-to-determine-absolut","errorCode":null,"errorMessage":"server: NewDoltServer: failed to determine absolute path of doltBinExec","messagePattern":"server: NewDoltServer: failed to determine absolute path of doltBinExec","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dbproxy/server/doltserver.go","lineNumber":75,"sourceCode":"\tcancel  context.CancelFunc\n\tpid     int\n}\n\nvar _ 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\")","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dbproxy/server/doltserver.go#L57-L93","documentation":"NewDoltServer resolves doltBinExec to an absolute path with filepath.Abs so the spawned `dolt sql-server` child process gets a stable, cwd-independent binary path. filepath.Abs only fails when the process's current working directory cannot be determined (deleted cwd or getwd failure) and the input path is relative. The library discards the underlying error and returns this fixed message.","triggerScenarios":"Calling NewDoltServer with a relative doltBinExec (e.g. \"./bin/dolt\") while the process cwd is invalid: the working directory was deleted after the process started, or the OS getwd call failed. An absolute doltBinExec would never hit this branch.","commonSituations":"Long-running daemons whose working directory was removed or replaced (e.g. tmp cleanup deleted the cwd); launching bd from a shell sitting in a since-deleted directory; container environments where the entrypoint chdirs into an erased path.","solutions":["Pass an absolute doltBinExec (filepath.Abs it yourself at startup, when the cwd is still valid, and cache the result)","Check the process cwd: ls -l /proc/$(pgrep -f bd)/cwd — if it is deleted, restart the process from a valid directory","Restart the application from a directory that exists"],"exampleFix":"// before\nsrv, err := server.NewDoltServer(\"./bin/dolt\", rootDir, cfgPath, logPath, 0, db)\n// after\nabsBin, err := filepath.Abs(\"./bin/dolt\") // do this early, while cwd is valid\nif err != nil { return err }\nsrv, err := server.NewDoltServer(absBin, rootDir, cfgPath, logPath, 0, db)","handlingStrategy":"validation","validationCode":"bin, err := filepath.Abs(doltBinExec)\nif err != nil { return fmt.Errorf(\"cannot resolve dolt binary path (cwd invalid?): %w\", err) }\nif _, err := os.Stat(bin); err != nil { return fmt.Errorf(\"dolt binary not found at %s: %w\", bin, err) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve all paths (binary, rootDir, config, log) to absolute at process startup, before any chdir","Cache os.Getwd() early; if it fails at startup, fail fast with a clear message","Never rely on relative paths in long-running daemons or containers","Alert on cwd deletion in supervised services (systemd WorkingDirectory checks)"],"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"}