{"record":{"id":"deb5a80dc25517c9","repo":"gastownhall/beads","slug":"not-a-git-repository-deb5a8","errorCode":null,"errorMessage":"not a git repository","messagePattern":"not a git repository","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/beads/fingerprint.go","lineNumber":59,"sourceCode":"// can tell a canonical remote-derived fingerprint from the path fallback\n// (bd-46vla: on a synced clone without the canonical origin remote, a\n// path-fallback mismatch against the stored id is cosmetic, and stamping the\n// local value into the versioned metadata table propagates it to every clone).\n//\n// GH#2867: When running from a git worktree, the path-based fallback (no remote)\n// uses the main repository root instead of the worktree root. This ensures all\n// worktrees sharing a database produce the same fingerprint. Without this,\n// worktree operations would compute a different repo_id and bd doctor would\n// report a fingerprint mismatch.\nfunc ComputeRepoIDForPathWithSource(repoPath string) (string, RepoIDSource, error) {\n\toutput, err := runGitInRepo(repoPath, \"config\", \"--get\", \"remote.origin.url\")\n\tif err != nil {\n\t\t// No remote configured — fall back to path-based fingerprint.\n\t\t// Use --git-common-dir to derive the main repo root so that\n\t\t// worktrees produce the same fingerprint as the main checkout.\n\t\trepoRoot, rootErr := mainRepoRootForPath(repoPath)\n\t\tif rootErr != nil {\n\t\t\treturn \"\", \"\", fmt.Errorf(\"not a git repository\")\n\t\t}\n\n\t\tnormalized := normalizedRepoPath(repoRoot)\n\t\thash := sha256.Sum256([]byte(normalized))\n\t\treturn hex.EncodeToString(hash[:16]), RepoIDSourcePath, nil\n\t}\n\n\trepoURL := strings.TrimSpace(string(output))\n\tcanonical, err := canonicalizeGitURL(repoURL)\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to canonicalize URL: %w\", err)\n\t}\n\n\thash := sha256.Sum256([]byte(canonical))\n\treturn hex.EncodeToString(hash[:16]), RepoIDSourceRemote, nil\n}\n\nfunc canonicalizeGitURL(rawURL string) (string, error) {","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/beads/fingerprint.go#L41-L77","documentation":"ComputeRepoIDForPathWithSource computes a stable repository ID from either the git remote URL or, as fallback, the normalized repo path. When no remote is configured it falls back to path fingerprinting via mainRepoRootForPath; if that also fails (git rev-parse cannot find a repo), it concludes the path is not inside a git repository and returns this error.","triggerScenarios":"Calling ComputeRepoIDForPath/ComputeRepoIDForPathWithSource with a repoPath that is outside any git work tree, or where `git rev-parse --show-toplevel --git-common-dir` fails (no .git, bare-ish context, or git not able to resolve from that directory).","commonSituations":"Running bd in a plain directory that was never `git init`ed; passing a wrong/typo'd path; operating in a directory whose .git was deleted; calling the API with an empty path while the process CWD is not a repo.","solutions":["Run `git init` in the directory (or move into an existing repository) before computing the repo ID","Verify the path with `git -C <path> rev-parse --show-toplevel` to confirm it is a git repository","Pass the correct repoPath to the function if a wrong path was supplied","Restore a deleted .git directory from backup or re-clone"],"exampleFix":"// before\nid, _ := beads.ComputeRepoIDForPath(\"/home/me/notes\") // not a repo\n// after\nif _, err := os.Stat(\"/home/me/notes/.git\"); err == nil {\n    id, _ = beads.ComputeRepoIDForPath(\"/home/me/notes\")\n}\n","handlingStrategy":"validation","validationCode":"func isGitRepo(p string) bool {\n    cmd := exec.Command(\"git\", \"-C\", p, \"rev-parse\", \"--show-toplevel\")\n    return cmd.Run() == nil\n}","typeGuard":null,"tryCatchPattern":"id, err := beads.ComputeRepoIDForPath(path)\nif err != nil && err.Error() == \"not a git repository\" {\n    return fmt.Errorf(\"%s is not a git repo; run git init first\", path)\n}","preventionTips":["Check `git rev-parse --is-inside-work-tree` before calling fingerprint APIs","Never run bd in directories without a .git","Ensure git is installed and on PATH","Pass explicit, verified repo paths rather than relying on CWD"],"tags":["git","fingerprint","repository"],"backgroundTag":"not-a-git-repository","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}