gastownhall/beads · error

server: NewDoltServer: failed to determine absolute path of

Error message

server: NewDoltServer: failed to determine absolute path of logFilePath

What it means

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.

Source

Thrown at internal/storage/dbproxy/server/doltserver.go:93

		return nil, errors.New("server: NewDoltServer: failed to determine absolute path of doltBinExec")
	}
	absRootDir, err := filepath.Abs(rootDir)
	if err != nil {
		return nil, errors.New("server: NewDoltServer: failed to determine absolute path of rootDir")
	}
	absConfigPath, err := filepath.Abs(configPath)
	if err != nil {
		return nil, errors.New("server: NewDoltServer: failed to determine absolute path of configPath")
	}
	cfg, err := servercfg.YamlConfigFromFile(filesys.LocalFS, configPath)
	if err != nil {
		return nil, fmt.Errorf("server: NewDoltServer: parse config %q: %w", configPath, err)
	}
	var logFile *os.File
	if logFilePath != "" {
		absLogFilePath, err := filepath.Abs(logFilePath)
		if err != nil {
			return nil, errors.New("server: NewDoltServer: failed to determine absolute path of logFilePath")
		}
		logFile, err = os.OpenFile(absLogFilePath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o600) //nolint:gosec // logFilePath is caller-derived, not user-request input
		if err != nil {
			return nil, fmt.Errorf("server: NewDoltServer: open log %q: %w", logFilePath, err)
		}
	}
	if keepAlivePeriod == 0 {
		keepAlivePeriod = defaultKeepAlivePeriod
	}
	sum := sha256.Sum256([]byte(absRootDir))
	return &DoltServer{
		id:              hex.EncodeToString(sum[:]),
		doltBinExec:     absDoltBinExec,
		rootDir:         absRootDir,
		configPath:      absConfigPath,
		database:        database,
		config:          cfg,
		keepAlivePeriod: keepAlivePeriod,

View on GitHub (pinned to 71377f2769)

Solutions

  1. Pass an absolute logFilePath, or pass "" to disable file logging if a log file is not needed
  2. Resolve the log path once at startup with filepath.Abs while the cwd is still valid
  3. Restart the process from an existing working directory

Example fix

// before
srv, err := server.NewDoltServer(bin, root, cfg, "logs/dolt.log", 0, db)
// after
absLog, err := filepath.Abs("logs/dolt.log")
if err != nil { return err }
srv, err := server.NewDoltServer(bin, root, cfg, absLog, 0, db)
Defensive patterns

Strategy: validation

Validate before calling

var absLog string
if logFilePath != "" {
    absLog, err = filepath.Abs(logFilePath)
    if err != nil { return fmt.Errorf("cannot resolve log path (cwd invalid?): %w", err) }
    if err := os.MkdirAll(filepath.Dir(absLog), 0o755); err != nil { return err }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/033d5a99adc922a4. Report an issue: GitHub.