plandex-ai/plandex · error

error committing rejected changes: %v

Error message

error committing rejected changes: %v

What it means

Returned by RejectAllChangesHandler when repo.GitAddAndCommit(branch, ...) fails after db.RejectAllResults succeeded. The DB rejection is already applied but the git commit recording it could not be made, leaving the repo and DB out of sync; the operation is wrapped and surfaced as HTTP 500 'Error rejecting all changes'.

Source

Thrown at app/server/handlers/plans_changes.go:287

	err := db.ExecRepoOperation(db.ExecRepoOperationParams{
		OrgId:          auth.OrgId,
		UserId:         auth.User.Id,
		PlanId:         planId,
		Branch:         branch,
		Scope:          db.LockScopeWrite,
		Ctx:            ctx,
		CancelFn:       cancel,
		ClearRepoOnErr: true,
	}, func(repo *db.GitRepo) error {
		err := db.RejectAllResults(auth.OrgId, planId)
		if err != nil {
			return err
		}

		err = repo.GitAddAndCommit(branch, "🚫 Rejected all pending changes")
		if err != nil {
			return fmt.Errorf("error committing rejected changes: %v", err)
		}

		return nil
	})

	if err != nil {
		log.Printf("Error rejecting all changes: %v\n", err)
		http.Error(w, "Error rejecting all changes: "+err.Error(), http.StatusInternalServerError)
		return
	}

	log.Println("Successfully rejected all changes for plan", planId)
}

func RejectFileHandler(w http.ResponseWriter, r *http.Request) {
	log.Println("Received request for RejectFileHandler")

	auth := Authenticate(w, r, true)

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check the wrapped git error in the logs (lock file, identity, dirty tree)
  2. Remove any stale .git/index.lock in the plan's repo working dir
  3. Configure git user.name/user.email in the server environment
  4. Re-run the reject operation; ClearRepoOnErr will re-clone a corrupt repo
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := os.Stat(repoWorkdir + "/.git"); err != nil {
    return fmt.Errorf("plan repo is not initialized: %w", err)
}
if _, err := os.Stat(repoWorkdir + "/.git/index.lock"); err == nil {
    return errors.New("git index is locked; another operation may be in progress")
}

Try / catch

err := repo.GitAddAndCommit(branch, "🚫 Rejected all pending changes")
if err != nil {
    if strings.Contains(err.Error(), "nothing to commit") {
        return nil
    }
    return fmt.Errorf("error committing rejected changes: %w", err)
}

Prevention

When it happens

Trigger: POSTing reject-all for a plan when the git working tree has nothing to commit, an index lock exists (.git/index.lock), git identity is unconfigured, or the branch is in a conflicted state.

Common situations: Concurrent operations leaving a stale index.lock; repo clone cleared or corrupted (ClearRepoOnErr paths); missing git user.email/user.name in the server environment; branch checked out elsewhere.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/04713b1bbbed19d3. Report an issue: GitHub.