plandex-ai/plandex · error
error committing changes: %v
Error message
error committing changes: %v
What it means
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'.
Source
Thrown at app/server/handlers/plans_context.go:281
updateRes, err = db.UpdateContexts(db.UpdateContextsParams{
Req: &requestBody,
OrgId: auth.OrgId,
Plan: plan,
BranchName: branchName,
})
if err != nil {
return err
}
if updateRes.MaxTokensExceeded {
return nil
}
err = repo.GitAddAndCommit(branchName, updateRes.Msg)
if err != nil {
return fmt.Errorf("error committing changes: %v", err)
}
return nil
})
if err != nil {
log.Printf("Error error updating contexts: %v\n", err)
http.Error(w, "Error error updating contexts: "+err.Error(), http.StatusInternalServerError)
return
}
if updateRes.MaxTokensExceeded {
log.Printf("The total number of tokens (%d) exceeds the maximum allowed (%d)", updateRes.TotalTokens, updateRes.MaxTokens)
bytes, err := json.Marshal(updateRes)
if err != nil {
log.Printf("Error marshalling response: %v\n", err)
http.Error(w, "Error marshalling response: "+err.Error(), http.StatusInternalServerError)View on GitHub (pinned to e2d772072e)
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
Defensive patterns
Strategy: try-catch
Validate before calling
if updateRes == nil || updateRes.Msg == "" {
return errors.New("no commit message produced by UpdateContexts; skipping commit")
}
if _, err := os.Stat(repoWorkdir + "/.git"); err != nil {
return fmt.Errorf("plan repo missing: %w", err)
} Try / catch
err := repo.GitAddAndCommit(branchName, updateRes.Msg)
if err != nil {
if strings.Contains(err.Error(), "nothing to commit") {
return nil
}
return fmt.Errorf("error committing changes: %w", err)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Context content change that produces no file diff (e.g. metadata-only update); concurrent context updates racing; disk or permission problems on repo storage.
Related errors
- error committing files to git repository for dir: %s, err: %
- error committing files to git repository for dir: %s, err: %
- error committing plan: %v
- error committing rejected changes: %v
- error getting git root: %s
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/27aaeb023f8f4d73.
Report an issue: GitHub.