{"record":{"id":"2d4125cc256c7f66","repo":"plandex-ai/plandex","slug":"error-committing-plan-v","errorCode":null,"errorMessage":"error committing plan: %v","messagePattern":"error committing plan: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/result_helpers.go","lineNumber":784,"sourceCode":"\t}\n\tsort.Strings(sortedFiles)\n\tfor _, path := range sortedFiles {\n\t\tmsg += fmt.Sprintf(\"\\n • 📄 %s\", path)\n\t}\n\tmsg += \"\\n\" + \"✏️  \" + params.CommitMsg\n\n\tif loadContextRes != nil && !loadContextRes.MaxTokensExceeded {\n\t\tmsg += \"\\n\\n\" + loadContextRes.Msg\n\t}\n\n\tif updateContextRes != nil && !updateContextRes.MaxTokensExceeded {\n\t\tmsg += \"\\n\\n\" + updateContextRes.Msg\n\t}\n\n\terr = repo.GitAddAndCommit(branchName, msg)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error committing plan: %v\", err)\n\t}\n\n\treturn nil\n}\n\nfunc RejectAllResults(orgId, planId string) error {\n\tresultsDir := getPlanResultsDir(orgId, planId)\n\n\tfiles, err := os.ReadDir(resultsDir)\n\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn nil\n\t\t}\n\n\t\treturn fmt.Errorf(\"error reading results dir: %v\", err)\n\t}\n","sourceCodeStart":766,"sourceCodeEnd":802,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/result_helpers.go#L766-L802","documentation":"ApplyPlan finishes by creating a git commit summarizing the applied plan via repo.GitAddAndCommit(branchName, msg). If git add/commit fails, the error is wrapped with this message. The apply has already been recorded on disk, but the commit that materializes it on the branch did not happen.","triggerScenarios":"GitAddAndCommit fails — the branch does not exist or is not checked out, git index is locked (.git/index.lock), nothing staged, git identity (user.name/user.email) not configured, or the repo is in a detached/conflicted state.","commonSituations":"Concurrent operations leaving a stale index.lock; branch deleted or renamed between apply steps; fresh clone/CI container missing git config user.email; merge conflicts from earlier failed applies.","solutions":["Inspect the wrapped git error; if it mentions index.lock, remove the stale .git/index.lock once no git process is running","Confirm branchName exists and is checked out in the repo before ApplyPlan's commit step","Configure git identity in the runtime environment: git config user.name/user.email","Resolve any outstanding merge conflicts, then retry the apply"],"exampleFix":"// before\nerr = repo.GitAddAndCommit(branchName, msg)\nif err != nil {\n    return fmt.Errorf(\"error committing plan: %v\", err)\n}\n// after: clean stale lock and ensure identity before committing\nlockPath := filepath.Join(repo.Path, \".git\", \"index.lock\")\nif _, statErr := os.Stat(lockPath); statErr == nil {\n    os.Remove(lockPath) // only when no other git process is active\n}\nif err := repo.GitAddAndCommit(branchName, msg); err != nil {\n    return fmt.Errorf(\"error committing plan: %v\", err)\n}","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(filepath.Join(repo.Path, \".git\")); err != nil {\n    return fmt.Errorf(\"not a git repo: %v\", err)\n}\nif _, err := os.Stat(filepath.Join(repo.Path, \".git\", \"index.lock\")); err == nil {\n    return fmt.Errorf(\"git index is locked; another git operation may be running\")\n}","typeGuard":null,"tryCatchPattern":"if err := repo.GitAddAndCommit(branchName, msg); err != nil {\n    if strings.Contains(err.Error(), \"index.lock\") {\n        log.Printf(\"git index locked; retry after removing stale lock\")\n    }\n    return fmt.Errorf(\"error committing plan: %v\", err)\n}","preventionTips":["Configure git user.name/user.email in all runtime environments (CI containers included)","Serialize git-mutating operations per repository with an application-level lock","Verify the target branch exists and is checked out before starting ApplyPlan","Clean stale .git/index.lock only after confirming no git process is active"],"tags":["git","go","commit"],"backgroundTag":"git-commit-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}