{"record":{"id":"3dee7f810047a9b6","repo":"gastownhall/beads","slug":"failed-to-fingerprint-target-git-directory-w","errorCode":null,"errorMessage":"failed to fingerprint target git directory: %w","messagePattern":"failed to fingerprint target git directory: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/worktree_cmd.go","lineNumber":1028,"sourceCode":"\t}\n\tgitDirInfo, err := os.Lstat(gitDir)\n\tif err != nil {\n\t\treturn pinnedWorktreeTarget{}, fmt.Errorf(\"failed to pin target git directory identity: %w\", err)\n\t}\n\tif gitDirInfo.Mode()&os.ModeSymlink != 0 || !gitDirInfo.IsDir() {\n\t\treturn pinnedWorktreeTarget{}, fmt.Errorf(\"target git directory is not a real directory: %s\", gitDir)\n\t}\n\tgitMarkerPath := filepath.Join(worktree.path, \".git\")\n\tgitMarkerInfo, err := os.Lstat(gitMarkerPath)\n\tif err != nil {\n\t\treturn pinnedWorktreeTarget{}, fmt.Errorf(\"failed to pin target git marker identity: %w\", err)\n\t}\n\tif gitMarkerInfo.Mode()&os.ModeSymlink != 0 || !gitMarkerInfo.Mode().IsRegular() {\n\t\treturn pinnedWorktreeTarget{}, fmt.Errorf(\"target git marker is not a regular file: %s\", gitMarkerPath)\n\t}\n\tgitDirFingerprint, err := fingerprintWorktreeFilesystem(gitDir)\n\tif err != nil {\n\t\treturn pinnedWorktreeTarget{}, fmt.Errorf(\"failed to fingerprint target git directory: %w\", err)\n\t}\n\tgitMarkerFingerprint, err := fingerprintWorktreeFilesystem(gitMarkerPath)\n\tif err != nil {\n\t\treturn pinnedWorktreeTarget{}, fmt.Errorf(\"failed to fingerprint target git marker: %w\", err)\n\t}\n\tstatusFingerprint, err := fingerprintWorktreeStatusPaths(worktree.path, string(statusOutput))\n\tif err != nil {\n\t\treturn pinnedWorktreeTarget{}, fmt.Errorf(\"failed to fingerprint target changes: %w\", err)\n\t}\n\n\treturn pinnedWorktreeTarget{\n\t\tpath:                 filepath.Clean(worktree.path),\n\t\tpathInfo:             pathInfo,\n\t\tgitDir:               gitDir,\n\t\tgitDirInfo:           gitDirInfo,\n\t\tgitMarkerInfo:        gitMarkerInfo,\n\t\tgitDirFingerprint:    gitDirFingerprint,\n\t\tgitMarkerFingerprint: gitMarkerFingerprint,","sourceCodeStart":1010,"sourceCodeEnd":1046,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/worktree_cmd.go#L1010-L1046","documentation":"bd computes a SHA-256 fingerprint of the target worktree's git directory (walk of every file: name, mode, size, mtime, content) to pin its identity before removal. This wraps any error from that walk — unreadable files/dirs, permission errors, files vanishing mid-walk, symlink read failures.","triggerScenarios":"`bd worktree remove <name>` or observeRevalidation when `filepath.WalkDir` over the worktree's gitdir fails: permission denied, file deleted concurrently, broken stat on an entry, or an unreadable symlink.","commonSituations":"Root-owned files inside .git/worktrees/<name>; antivirus/backup tools touching the gitdir during the scan; NFS/network filesystems returning transient stat errors; concurrent git operations deleting metadata mid-run.","solutions":["Fix permissions on the gitdir: `chmod -R u+rwX /repo/.git/worktrees/<name>`","Retry the command — transient I/O races (files appearing/disappearing) often clear on a second run","Stop processes (IDEs, sync tools) that touch the repo, or exclude it from real-time scanning"],"exampleFix":"// before\nls -la /repo/.git/worktrees/mywt   # root-owned index.lock\n// after\nsudo chown -R \"$USER\" /repo/.git/worktrees/mywt && bd worktree remove mywt","handlingStrategy":"retry","validationCode":"// ensure the gitdir is fully readable first\nreturn filepath.Walk(gitDir, func(p string, info os.FileInfo, err error) error {\n    if err != nil { return err }\n    return nil\n})","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if errors.Is(err, fs.ErrPermission) {\n        // fix perms and retry once\n    }\n    time.Sleep(time.Second)\n    err = retryInspect()  // transient walk races often clear\n}","preventionTips":["Keep IDEs/AV/backup tools from touching .git during bd operations","Run bd as the same user that owns the repository files","Avoid running concurrent git commands against the same worktree"],"tags":["git","worktree","permissions"],"backgroundTag":"filesystem-fingerprint-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}