plandex-ai/plandex · error

Error renaming plan:

Error message

Error renaming plan: 

What it means

RenamePlanHandler returns this 500 when db.RenamePlan fails to persist the new name. Ownership and name validation passed, but the database update errored; the underlying error text is appended to the response. Note the third argument nil suggests an optional tx/lock parameter that can influence behavior.

Source

Thrown at app/server/handlers/plans_crud.go:201

	}

	if plan.OwnerId != auth.User.Id {
		log.Println("Only the plan owner can rename a plan")
		http.Error(w, "Only the plan owner can rename a plan", http.StatusForbidden)
		return
	}

	if requestBody.Name == "" {
		log.Println("Name cannot be empty")
		http.Error(w, "Name cannot be empty", http.StatusBadRequest)
		return
	}

	err := db.RenamePlan(planId, requestBody.Name, nil)

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

	log.Println("Successfully renamed plan")
}

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

	auth := Authenticate(w, r, true)
	if auth == nil {
		return
	}

	vars := mux.Vars(r)
	planId := vars["planId"]

	log.Println("planId: ", planId)

View on GitHub (pinned to e2d772072e)

Solutions

  1. Inspect the wrapped database error in the response body/server log to classify the failure
  2. Retry the rename if it was transient (connection reset) or pick a different name on unique violation
  3. Confirm the plan still exists (it may have been deleted concurrently) — the response 404 vs 500 will clarify
  4. Check for lock contention with active plan sessions and retry after they finish

Example fix

// before
err := db.RenamePlan(planId, requestBody.Name, nil)
// after
err := db.RenamePlan(planId, requestBody.Name, nil)
if err != nil {
	var pgErr *pgconn.PgError
	if errors.As(err, &pgErr) && pgErr.Code == "23505" {
		http.Error(w, "A plan with that name already exists", http.StatusConflict); return
	}
	
}
Defensive patterns

Strategy: retry

Validate before calling

if _, err := db.Conn.Exec("SELECT 1 FROM plans WHERE id=$1", planId); err != nil { return err } // row still exists

Type guard

func isUniqueViolation(err error) bool { var pgErr *pgconn.PgError; return errors.As(err, &pgErr) && pgErr.Code == "23505" }

Try / catch

err := db.RenamePlan(planId, requestBody.Name, nil)
if err != nil {
	if isUniqueViolation(err) { http.Error(w, "name already in use", http.StatusConflict); return }
	if isTransientDBErr(err) { /* retry with backoff */ return }
	http.Error(w, "Error renaming plan", http.StatusInternalServerError)
	return
}

Prevention

When it happens

Trigger: POST rename passing validation but db.RenamePlan(planId, requestBody.Name, nil) fails: DB connection loss, statement timeout, plans row deleted concurrently between authorizePlan and the update, unique constraint on (project_id, owner_id, name), or lock contention with an active plan operation.

Common situations: Postgres restart/failover mid-request; plan deleted by another session during the rename; renaming to a name that already exists for the same owner+project hitting a unique index; long-running lock held by an active generation stream.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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