{"record":{"id":"4a107907140ec861","repo":"gastownhall/beads","slug":"resolve-path-w","errorCode":null,"errorMessage":"resolve path: %w","messagePattern":"resolve path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/bd/doctor/hooks_migration.go","lineNumber":60,"sourceCode":"}\n\n// HookMigrationPlan summarizes migration state for all managed hooks.\ntype HookMigrationPlan struct {\n\tPath                string                  `json:\"path\"`\n\tRepoRoot            string                  `json:\"repo_root,omitempty\"`\n\tHooksDir            string                  `json:\"hooks_dir,omitempty\"`\n\tIsGitRepo           bool                    `json:\"is_git_repo\"`\n\tHooks               []HookMigrationHookPlan `json:\"hooks\"`\n\tTotalHooks          int                     `json:\"total_hooks\"`\n\tNeedsMigrationCount int                     `json:\"needs_migration_count\"`\n\tBrokenMarkerCount   int                     `json:\"broken_marker_count\"`\n}\n\n// PlanHookMigration builds a read-only migration plan for git hooks.\nfunc PlanHookMigration(path string) (HookMigrationPlan, error) {\n\tabsPath, err := filepath.Abs(path)\n\tif err != nil {\n\t\treturn HookMigrationPlan{}, fmt.Errorf(\"resolve path: %w\", err)\n\t}\n\n\tplan := HookMigrationPlan{\n\t\tPath:       absPath,\n\t\tTotalHooks: len(managedHookNames),\n\t\tHooks:      make([]HookMigrationHookPlan, 0, len(managedHookNames)),\n\t}\n\n\trepoRoot, hooksDir, err := resolveGitHooksDir(absPath)\n\tif err != nil {\n\t\tvar exitErr *exec.ExitError\n\t\tif errors.As(err, &exitErr) {\n\t\t\t// Not a git repository (or no git metadata reachable from path).\n\t\t\treturn plan, nil\n\t\t}\n\t\treturn HookMigrationPlan{}, err\n\t}\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/doctor/hooks_migration.go#L42-L78","documentation":"PlanHookMigration first converts the user-supplied path to an absolute path with filepath.Abs before inspecting git hooks. filepath.Abs fails only when obtaining the current working directory fails, and the failure is wrapped as 'resolve path'. This is one of the rarest Go path errors because it depends on the process cwd, not the argument.","triggerScenarios":"filepath.Abs(path) returns an error, which happens when the process's current working directory has been deleted or cannot be stat'd (os.Getwd fails).","commonSituations":"Running bd from a directory that was deleted or replaced while the shell sat in it; a deleted worktree; containers/k8s exec sessions whose cwd vanished; running via a symlinked cwd that no longer resolves.","solutions":["cd to a valid existing directory (e.g. the repo root) and re-run the command.","Open a fresh shell session if your current directory was deleted or renamed.","Pass an absolute path for the repo so the resolution is less dependent on cwd.","In scripts, verify the working directory exists before invoking bd (test -d \"$PWD\")."],"exampleFix":"// before\n$ cd /tmp/some-deleted-dir\n$ bd doctor hooks --plan .\nError: resolve path: getwd: no such file or directory\n// after\n$ cd /path/to/repo\n$ bd doctor hooks --plan .","handlingStrategy":"validation","validationCode":"if _, err := os.Getwd(); err != nil {\n    return fmt.Errorf(\"current working directory is unusable: %w\", err)\n}\nif _, err := os.Stat(path); err != nil {\n    return fmt.Errorf(\"target path %q does not exist: %w\", path, err)\n}","typeGuard":null,"tryCatchPattern":"plan, err := doctor.PlanHookMigration(path)\nif err != nil && strings.HasPrefix(err.Error(), \"resolve path:\") {\n    // recover by cd'ing to a valid directory or passing an absolute path\n    return retryWithAbsPath\n}","preventionTips":["Always launch bd from an existing directory; open a new shell after deleting a cwd.","Pass absolute repo paths in scripts to reduce cwd dependence.","In containers, verify WORKDIR exists before exec-ing commands."],"tags":["filesystem","paths","git-hooks"],"backgroundTag":"cwd-unresolved","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}