gastownhall/beads · error

resolve path: %w

Error message

resolve path: %w

What it means

ParseFile fails to convert the given path to an absolute path via filepath.Abs and wraps the OS error with this prefix. filepath.Abs only fails when os.Getwd() fails (e.g. the current working directory was deleted), so this is rare and signals a broken process environment rather than a bad path string.

Source

Thrown at internal/formula/parser.go:124

	if home, err := os.UserHomeDir(); err == nil {
		addPath(filepath.Join(home, ".beads", "formulas"))
	}

	// Orchestrator formulas (via GT_ROOT)
	if gtRoot := os.Getenv("GT_ROOT"); gtRoot != "" {
		addPath(filepath.Join(gtRoot, ".beads", "formulas"))
	}

	return paths
}

// ParseFile parses a formula from a file path.
// Detects format from extension: .formula.toml or .formula.json
func (p *Parser) ParseFile(path string) (*Formula, error) {
	// Check cache first
	absPath, err := filepath.Abs(path)
	if err != nil {
		return nil, fmt.Errorf("resolve path: %w", err)
	}

	if cached, ok := p.cache[absPath]; ok {
		return cached, nil
	}

	// Read and parse the file
	// #nosec G304 -- absPath comes from controlled search paths or explicit user input
	data, err := os.ReadFile(absPath)
	if err != nil {
		return nil, fmt.Errorf("read %s: %w", path, err)
	}

	// Detect format from extension
	var formula *Formula
	if strings.HasSuffix(path, FormulaExtTOML) {
		formula, err = p.ParseTOML(data)
	} else {

View on GitHub (pinned to 71377f2769)

Solutions

  1. Re-cd to a valid working directory before calling ParseFile.
  2. Pass an absolute path — filepath.Abs returns absolute paths unchanged without needing Getwd, avoiding the failure.
  3. Restart the process from a valid directory.

Example fix

// before
f, err := parser.ParseFile("formulas/x.formula.toml") // cwd deleted
// after
f, err := parser.ParseFile("/repo/.beads/formulas/x.formula.toml") // absolute path
Defensive patterns

Strategy: try-catch

Try / catch

f, err := parser.ParseFile(p)
if err != nil {
	if strings.HasPrefix(err.Error(), "resolve path:") {
		// cwd is broken; fall back to absolute path
		if f2, err2 := parser.ParseFile("/repo/.beads/formulas/x.formula.toml"); err2 == nil {
			return f2, nil
		}
	}
	return err
}

Prevention

When it happens

Trigger: Calling Parser.ParseFile(path) while the process's working directory has been removed (or its permissions prevent stat), causing filepath.Abs' internal os.Getwd() to fail.

Common situations: Long-running agent process whose cwd (a temp dir or checked-out branch) was deleted; running inside a container where the workdir was removed; cwd permissions changed mid-session.

Related errors


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