{"record":{"id":"d3613f2d3e9f95d9","repo":"gastownhall/beads","slug":"invalid-path-w","errorCode":null,"errorMessage":"invalid path: %w","messagePattern":"invalid path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/doctor/fix/common.go","lineNumber":69,"sourceCode":"\tbdPath, err := exec.LookPath(\"bd\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"bd binary not found in PATH: %w\", err)\n\t}\n\n\treturn bdPath, nil\n}\n\n// validateBeadsWorkspace ensures the path is a valid beads workspace before\n// attempting any fix operations. This prevents path traversal attacks.\nfunc validateBeadsWorkspace(path string) error {\n\t_, err := resolveWorkspaceBeadsDirs(path)\n\treturn err\n}\n\nfunc resolveWorkspaceBeadsDirs(path string) (workspaceBeadsDirs, error) {\n\tabsPath, err := filepath.Abs(path)\n\tif err != nil {\n\t\treturn workspaceBeadsDirs{}, fmt.Errorf(\"invalid path: %w\", err)\n\t}\n\n\tdirs := workspaceBeadsDirs{\n\t\tlocal:    filepath.Join(absPath, \".beads\"),\n\t\tresolved: beads.ResolveBeadsDirForRepo(absPath),\n\t}\n\n\tif info, err := os.Stat(dirs.resolved); err != nil || !info.IsDir() {\n\t\treturn workspaceBeadsDirs{}, fmt.Errorf(\"not a beads workspace: .beads directory not found for %s\", absPath)\n\t}\n\n\treturn dirs, nil\n}\n\nfunc resolvedWorkspaceBeadsDir(path string) (string, error) {\n\tdirs, err := resolveWorkspaceBeadsDirs(path)\n\tif err != nil {\n\t\treturn \"\", err","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/doctor/fix/common.go#L51-L87","documentation":"resolveWorkspaceBeadsDirs converts the given workspace path to an absolute path before locating .beads directories. If filepath.Abs fails (which requires the process working directory to be resolvable), the whole directory resolution fails with this wrapped error.","triggerScenarios":"filepath.Abs(path) returns an error in resolveWorkspaceBeadsDirs (cmd/bd/doctor/fix/common.go:69) — almost always because the current working directory was deleted or is unreadable when a relative path is passed to validateBeadsWorkspace, resolvedWorkspaceBeadsDir, or Permissions.","commonSituations":"Running a fix from a shell whose cwd was removed (e.g. after `rm -rf` of the directory in another terminal); containers that start in a deleted mount point; relative path passed while process cwd is invalid.","solutions":["Pass an absolute path to the API to bypass cwd resolution entirely.","cd to a valid directory (e.g. the workspace root) before running the command.","Restart the shell/process if its cwd was deleted, then re-run.","Check the wrapped os.Getwd-style error in %w to confirm the cwd problem."],"exampleFix":"// before\nvalidateBeadsWorkspace(\".\")           // fails if cwd deleted\n// after\nvalidateBeadsWorkspace(\"/path/to/repo\") // absolute path, no cwd dependency","handlingStrategy":"validation","validationCode":"abs, err := filepath.Abs(path)\nif err != nil {\n\t// cwd unusable; switch to a valid directory or pass absolute path\n\treturn err\n}\nif fi, err := os.Stat(abs); err != nil || !fi.IsDir() {\n\treturn fmt.Errorf(\"workspace path missing: %s\", abs)\n}","typeGuard":null,"tryCatchPattern":"if err := fix.Permissions(path); err != nil && strings.Contains(err.Error(), \"invalid path\") {\n\t// retry with an absolute path from a valid working directory\n\treturn err\n}","preventionTips":["Always pass absolute workspace paths to fix APIs","Don't run commands from a deleted working directory","In containers, set WORKDIR to an existing directory","Validate the path exists before calling doctor fix functions"],"tags":["path","doctor","workspace","filesystem"],"backgroundTag":"invalid-path-resolution","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}