gastownhall/beads · error

uow: resolving server root dir: %w

Error message

uow: resolving server root dir: %w

What it means

filepath.Abs failed while converting serverRootDir to an absolute path. filepath.Abs only fails when getting the current working directory fails, which means the process has no readable working directory (e.g. it was deleted). The OS error is wrapped for detail.

Source

Thrown at internal/storage/uow/doltserver_provider.go:50

	if idleTimeout == 0 {
		idleTimeout = defaultProxyIdleTimeout
	}
	if database == "" {
		return nil, fmt.Errorf("uow: database name must not be empty (caller should default to %q)", "beads")
	}
	if err := backend.Validate(); err != nil {
		return nil, fmt.Errorf("uow: backend: %w", err)
	}
	if rootUser == "" {
		return nil, fmt.Errorf("uow: rootUser must not be empty")
	}
	if doltBinExec == "" {
		return nil, fmt.Errorf("uow: doltBinExec must not be empty")
	}

	absServerRootDir, err := filepath.Abs(serverRootDir)
	if err != nil {
		return nil, fmt.Errorf("uow: resolving server root dir: %w", err)
	}
	absDoltBinExec, err := filepath.Abs(doltBinExec)
	if err != nil {
		return nil, fmt.Errorf("uow: resolving dolt bin exec: %w", err)
	}

	if err := os.MkdirAll(absServerRootDir, config.BeadsDirPerm); err != nil {
		return nil, fmt.Errorf("uow: creating server root directory: %w", err)
	}

	ep, err := proxy.GetCreateDatabaseProxyServerEndpoint(absServerRootDir, proxy.OpenOpts{
		Backend:        backend,
		ConfigFilePath: serverConfigFilePath,
		LogFilePath:    serverLogFilePath,
		DoltBinPath:    absDoltBinExec,
		Database:       database,
		IdleTimeout:    idleTimeout,
		Port:           proxyPort,

View on GitHub (pinned to 71377f2769)

Solutions

  1. Pass an absolute serverRootDir so filepath.Abs is a no-op
  2. Recreate or cd back to a valid working directory before starting
  3. Restore read/execute permission on the current directory

Example fix

// before
prov, err := NewDoltServerUOWProvider(ctx, "beads-data", ...)
// after
rootDir, err := filepath.Abs("beads-data") // or use an absolute path from config
if err != nil { return err }
prov, err := NewDoltServerUOWProvider(ctx, rootDir, ...)
Defensive patterns

Strategy: validation

Validate before calling

if !filepath.IsAbs(serverRootDir) {
    abs, err := filepath.Abs(serverRootDir)
    if err != nil { return fmt.Errorf("cannot resolve server root dir (cwd unreadable?): %w", err) }
    serverRootDir = abs
}

Type guard

func isUsableAbsPath(p string) bool {
    abs, err := filepath.Abs(p)
    return err == nil && abs != ""
}

Try / catch

prov, err := NewDoltServerUOWProvider(...)
if err != nil && strings.Contains(err.Error(), "resolving server root dir") {
    // cwd is broken: switch to an absolute configured path and retry
    os.Chdir("/")
    prov, err = NewDoltServerUOWProvider(...)
}

Prevention

When it happens

Trigger: Calling NewDoltServerUOWProvider with a relative serverRootDir while os.Getwd() fails — the cwd was removed, or permission to read it was revoked.

Common situations: Daemon started in a directory that was later deleted; running from a container/privileged context where cwd is inaccessible; symlinked cwd cleaned up by a tmpfiles sweeper.

Related errors


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