{"record":{"id":"033d5a99adc922a4","repo":"gastownhall/beads","slug":"server-newdoltserver-failed-to-determine-absolut-033d5a","errorCode":null,"errorMessage":"server: NewDoltServer: failed to determine absolute path of logFilePath","messagePattern":"server: NewDoltServer: failed to determine absolute path of logFilePath","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dbproxy/server/doltserver.go","lineNumber":93,"sourceCode":"\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)\n\t\t}\n\t}\n\tif keepAlivePeriod == 0 {\n\t\tkeepAlivePeriod = defaultKeepAlivePeriod\n\t}\n\tsum := sha256.Sum256([]byte(absRootDir))\n\treturn &DoltServer{\n\t\tid:              hex.EncodeToString(sum[:]),\n\t\tdoltBinExec:     absDoltBinExec,\n\t\trootDir:         absRootDir,\n\t\tconfigPath:      absConfigPath,\n\t\tdatabase:        database,\n\t\tconfig:          cfg,\n\t\tkeepAlivePeriod: keepAlivePeriod,","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dbproxy/server/doltserver.go#L75-L111","documentation":"NewDoltServer resolves the optional logFilePath to an absolute path before opening it, so the dolt sql-server child writes its log to a stable location. filepath.Abs only fails when the process cwd cannot be determined (deleted cwd or getwd failure) and logFilePath was relative. This branch runs only when logFilePath is non-empty.","triggerScenarios":"Passing a non-empty relative logFilePath (e.g. \".beads/dolt.log\") to NewDoltServer while os.Getwd() fails because the working directory was deleted or is inaccessible. Passing \"\" (disable file logging) never reaches this code.","commonSituations":"Daemons whose cwd was removed by cleanup jobs; processes started in a tmp directory that was wiped; environments where getwd returns errors due to permissions on the cwd.","solutions":["Pass an absolute logFilePath, or pass \"\" to disable file logging if a log file is not needed","Resolve the log path once at startup with filepath.Abs while the cwd is still valid","Restart the process from an existing working directory"],"exampleFix":"// before\nsrv, err := server.NewDoltServer(bin, root, cfg, \"logs/dolt.log\", 0, db)\n// after\nabsLog, err := filepath.Abs(\"logs/dolt.log\")\nif err != nil { return err }\nsrv, err := server.NewDoltServer(bin, root, cfg, absLog, 0, db)","handlingStrategy":"validation","validationCode":"var absLog string\nif logFilePath != \"\" {\n    absLog, err = filepath.Abs(logFilePath)\n    if err != nil { return fmt.Errorf(\"cannot resolve log path (cwd invalid?): %w\", err) }\n    if err := os.MkdirAll(filepath.Dir(absLog), 0o755); err != nil { return err }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve the log path at startup and create its parent directory before opening","Pass \"\" explicitly when file logging is not wanted","Keep logs in a stable, non-ephemeral directory"],"tags":["go","filesystem","logging","path-resolution"],"backgroundTag":"cwd-unresolvable-path","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}