gastownhall/beads · error

resolve absolute path: %w

Error message

resolve absolute path: %w

What it means

DirToFileURL calls filepath.Abs on dir and wraps failure as "resolve absolute path: <cause>" before returning a file:// URL. filepath.Abs only errors when Getwd fails (e.g. relative resolution needs the current working directory and it was deleted). This is rare and environmental.

Source

Thrown at internal/storage/versioncontrolops/backup.go:54

// same name is overwritten. Mirrors the CLI: dolt backup restore [--force] <url> <db_name>
func BackupRestore(ctx context.Context, db DBConn, url, dbName string, force bool) error {
	if force {
		if _, err := db.ExecContext(ctx, "CALL DOLT_BACKUP('restore', '--force', ?, ?)", url, dbName); err != nil {
			return fmt.Errorf("restore from backup %s: %w", url, err)
		}
	} else {
		if _, err := db.ExecContext(ctx, "CALL DOLT_BACKUP('restore', ?, ?)", url, dbName); err != nil {
			return fmt.Errorf("restore from backup %s: %w", url, err)
		}
	}
	return nil
}

// DirToFileURL resolves dir to an absolute path and returns a file:// URL.
func DirToFileURL(dir string) (string, error) {
	abs, err := filepath.Abs(dir)
	if err != nil {
		return "", fmt.Errorf("resolve absolute path: %w", err)
	}
	return "file://" + abs, nil
}

// ExtractAddressConflictName parses the conflicting remote name from a Dolt
// "address conflict with a remote" error.
//
// Dolt returns errors of the form:
//
//	Error 1105: address conflict with a remote: 'name' -> url
//
// When BackupAdd fails because another remote (e.g. "default", registered by
// `bd backup init`) already points to the same URL, the caller can use the
// conflicting name to sync directly rather than treating it as a hard error.
// Returns "" if the error is not an address conflict.
func ExtractAddressConflictName(err error) string {
	if err == nil {
		return ""

View on GitHub (pinned to 71377f2769)

Solutions

  1. Pass an absolute directory path so filepath.Abs short-circuits without Getwd
  2. Restart the process from an existing working directory
  3. Check os.Getwd() health if the process runs long after directory cleanup

Example fix

// before
u, err := vcops.DirToFileURL("backups/db")
// after
u, err := vcops.DirToFileURL("/var/backups/db")
if err != nil { return fmt.Errorf("backup url: %w", err) }
Defensive patterns

Strategy: validation

Validate before calling

func safeDirToFileURL(dir string) (string, error) {
	if filepath.IsAbs(dir) { return "file://" + filepath.Clean(dir), nil }
	return vcops.DirToFileURL(dir)
}

Try / catch

u, err := vcops.DirToFileURL(dir)
if err != nil {
	if strings.Contains(err.Error(), "resolve absolute path") {
		return fmt.Errorf("cwd unavailable; pass an absolute path: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: DirToFileURL(dir) when filepath.Abs fails: the process's current working directory has been removed and dir is relative, so Getwd inside filepath.Abs errors.

Common situations: Running a long-lived process whose working directory was deleted (tmpdir cleanup); launching from a removed directory; container environments with cleaned cwd.

Related errors


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