{"record":{"id":"781abee2e36c1681","repo":"gastownhall/beads","slug":"git-rev-parse-timed-out-after-s","errorCode":null,"errorMessage":"git rev-parse timed out after %s","messagePattern":"git rev-parse timed out after (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/export_auto.go","lineNumber":894,"sourceCode":"\t}\n\tif err != nil {\n\t\tif trimmed := strings.TrimSpace(string(out)); trimmed != \"\" {\n\t\t\treturn fmt.Errorf(\"%w: %s\", err, trimmed)\n\t\t}\n\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc gitIndexLockPath(path string, env []string) (string, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), gitAddTimeout)\n\tdefer cancel()\n\tcmd := exec.CommandContext(ctx, \"git\", \"rev-parse\", \"--git-dir\")\n\tcmd.Dir = filepath.Dir(path)\n\tcmd.Env = env\n\tout, err := cmd.CombinedOutput()\n\tif ctx.Err() == context.DeadlineExceeded {\n\t\treturn \"\", fmt.Errorf(\"git rev-parse timed out after %s\", gitAddTimeout)\n\t}\n\tif err != nil {\n\t\tif trimmed := strings.TrimSpace(string(out)); trimmed != \"\" {\n\t\t\treturn \"\", fmt.Errorf(\"%w: %s\", err, trimmed)\n\t\t}\n\t\treturn \"\", err\n\t}\n\tgitDir := strings.TrimSpace(string(out))\n\tif gitDir == \"\" {\n\t\treturn \"\", nil\n\t}\n\tif !filepath.IsAbs(gitDir) {\n\t\tgitDir = filepath.Join(filepath.Dir(path), gitDir)\n\t}\n\treturn filepath.Join(gitDir, \"index.lock\"), nil\n}\n\n// scrubGitHookEnv returns env with the GIT_* variables that can poison","sourceCodeStart":876,"sourceCodeEnd":912,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/export_auto.go#L876-L912","documentation":"gitIndexLockPath runs `git rev-parse --git-dir` under a context timeout to locate the git directory for the lock preflight. If rev-parse exceeds gitAddTimeout, this error is returned and the lock check is abandoned, failing the git add preflight.","triggerScenarios":"`git rev-parse --git-dir` spawned by gitIndexLockPath (from gitAddFile during auto-export) hits context.DeadlineExceeded — slow filesystem or hung git subprocess.","commonSituations":"NFS/network-mounted repos, overloaded CI machines, git waiting on credential/maintenance hooks, or heavy disk I/O delaying even rev-parse.","solutions":["Retry the auto-export once the transient slowness clears","Investigate filesystem/git health (df, iostat, stray git processes) in the repo","Raise gitAddTimeout if the environment is consistently slow; otherwise stage manually with `git add`"],"exampleFix":"// before\n// git rev-parse timed out after 10s\n// after\n# verify repo is responsive\ngit rev-parse --git-dir\nbd sync","handlingStrategy":"retry","validationCode":"// Confirm git itself is responsive before automating\nctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\ndefer cancel()\nout, err := exec.CommandContext(ctx, \"git\", \"rev-parse\", \"--git-dir\").Output()\nif err != nil || len(bytes.TrimSpace(out)) == 0 {\n    fmt.Println(\"git not responsive or not a repo; abort auto-export\")\n}","typeGuard":null,"tryCatchPattern":"if err := autoExport(); err != nil && strings.Contains(err.Error(), \"rev-parse timed out\") {\n    // Transient slowness — retry after backoff or stage manually\n    time.Sleep(5 * time.Second)\n    runCmd(\"git\", \"add\", \".beads/issues.jsonl\")\n}","preventionTips":["Monitor filesystem latency on CI runners hosting large repos","Avoid competing heavy git operations during auto-export windows","Use local clones rather than network mounts for automated bd runs","Re-run with a longer timeout for very large worktrees"],"tags":["git","timeout","rev-parse"],"backgroundTag":"git-rev-parse-timeout","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}