{"record":{"id":"27aaeb023f8f4d73","repo":"plandex-ai/plandex","slug":"error-committing-changes-v-27aaeb","errorCode":null,"errorMessage":"error committing changes: %v","messagePattern":"error committing changes: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/plans_context.go","lineNumber":281,"sourceCode":"\t\tupdateRes, err = db.UpdateContexts(db.UpdateContextsParams{\n\t\t\tReq:        &requestBody,\n\t\t\tOrgId:      auth.OrgId,\n\t\t\tPlan:       plan,\n\t\t\tBranchName: branchName,\n\t\t})\n\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif updateRes.MaxTokensExceeded {\n\t\t\treturn nil\n\t\t}\n\n\t\terr = repo.GitAddAndCommit(branchName, updateRes.Msg)\n\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error committing changes: %v\", err)\n\t\t}\n\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\tlog.Printf(\"Error error updating contexts: %v\\n\", err)\n\t\thttp.Error(w, \"Error error updating contexts: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif updateRes.MaxTokensExceeded {\n\t\tlog.Printf(\"The total number of tokens (%d) exceeds the maximum allowed (%d)\", updateRes.TotalTokens, updateRes.MaxTokens)\n\t\tbytes, err := json.Marshal(updateRes)\n\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error marshalling response: %v\\n\", err)\n\t\t\thttp.Error(w, \"Error marshalling response: \"+err.Error(), http.StatusInternalServerError)","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/plans_context.go#L263-L299","documentation":"Returned by UpdateContextHandler (plans_context.go) when repo.GitAddAndCommit(branchName, updateRes.Msg) fails after db.UpdateContexts succeeded and token limits were not exceeded. The context update was persisted to the DB but the git commit recording the change on the plan branch failed, so the client gets HTTP 500 'Error error updating contexts'.","triggerScenarios":"Adding/updating plan contexts when the resulting git commit cannot be made: nothing changed in the working tree, git index lock present, unconfigured git identity, or repo clone missing.","commonSituations":"Context content change that produces no file diff (e.g. metadata-only update); concurrent context updates racing; disk or permission problems on repo storage.","solutions":["Read the wrapped git error for the specific git failure","Allow empty commits or skip committing when there is no diff","Clear stale .git/index.lock and check repo dir permissions","Retry the update; ClearRepoOnErr will rebuild a broken repo clone"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if updateRes == nil || updateRes.Msg == \"\" {\n    return errors.New(\"no commit message produced by UpdateContexts; skipping commit\")\n}\nif _, err := os.Stat(repoWorkdir + \"/.git\"); err != nil {\n    return fmt.Errorf(\"plan repo missing: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := repo.GitAddAndCommit(branchName, updateRes.Msg)\nif err != nil {\n    if strings.Contains(err.Error(), \"nothing to commit\") {\n        return nil\n    }\n    return fmt.Errorf(\"error committing changes: %w\", err)\n}","preventionTips":["Allow-empty commit or early-return when context updates yield no diff","Ensure git identity is configured in the deployment image","Re-clone corrupted repos via ClearRepoOnErr and alert on repeat occurrences"],"tags":["go","git","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-12T22:17:10.623Z"}