{"record":{"id":"18d3be08e2f31713","repo":"gastownhall/beads","slug":"resolve-path-w-18d3be","errorCode":null,"errorMessage":"resolve path: %w","messagePattern":"resolve path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/formula/parser.go","lineNumber":124,"sourceCode":"\tif home, err := os.UserHomeDir(); err == nil {\n\t\taddPath(filepath.Join(home, \".beads\", \"formulas\"))\n\t}\n\n\t// Orchestrator formulas (via GT_ROOT)\n\tif gtRoot := os.Getenv(\"GT_ROOT\"); gtRoot != \"\" {\n\t\taddPath(filepath.Join(gtRoot, \".beads\", \"formulas\"))\n\t}\n\n\treturn paths\n}\n\n// ParseFile parses a formula from a file path.\n// Detects format from extension: .formula.toml or .formula.json\nfunc (p *Parser) ParseFile(path string) (*Formula, error) {\n\t// Check cache first\n\tabsPath, err := filepath.Abs(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"resolve path: %w\", err)\n\t}\n\n\tif cached, ok := p.cache[absPath]; ok {\n\t\treturn cached, nil\n\t}\n\n\t// Read and parse the file\n\t// #nosec G304 -- absPath comes from controlled search paths or explicit user input\n\tdata, err := os.ReadFile(absPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"read %s: %w\", path, err)\n\t}\n\n\t// Detect format from extension\n\tvar formula *Formula\n\tif strings.HasSuffix(path, FormulaExtTOML) {\n\t\tformula, err = p.ParseTOML(data)\n\t} else {","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/formula/parser.go#L106-L142","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-cd to a valid working directory before calling ParseFile.","Pass an absolute path — filepath.Abs returns absolute paths unchanged without needing Getwd, avoiding the failure.","Restart the process from a valid directory."],"exampleFix":"// before\nf, err := parser.ParseFile(\"formulas/x.formula.toml\") // cwd deleted\n// after\nf, err := parser.ParseFile(\"/repo/.beads/formulas/x.formula.toml\") // absolute path","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"f, err := parser.ParseFile(p)\nif err != nil {\n\tif strings.HasPrefix(err.Error(), \"resolve path:\") {\n\t\t// cwd is broken; fall back to absolute path\n\t\tif f2, err2 := parser.ParseFile(\"/repo/.beads/formulas/x.formula.toml\"); err2 == nil {\n\t\t\treturn f2, nil\n\t\t}\n\t}\n\treturn err\n}","preventionTips":["Prefer passing absolute paths to ParseFile.","Avoid deleting the process's working directory while it runs (temp dirs, branch checkouts).","In long-running daemons, resolve and cache absolute formula paths at startup."],"tags":["go","filesystem","path"],"backgroundTag":"working-directory-missing","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}