plandex-ai/plandex · critical

Error updating project:

Error message

Error updating project: 

What it means

This HTTP 500 response means the SQL UPDATE projects SET name = $1 WHERE id = $2 failed at the database level. db.Conn.Exec returned a non-nil error — a connection failure, constraint violation, or driver error — so the rename never (necessarily) applied. The err.Error() detail is appended to the response and logged, so check the server log for the root cause.

Source

Thrown at app/server/handlers/projects.go:208

	var requestBody shared.RenameProjectRequest
	if err := json.Unmarshal(body, &requestBody); err != nil {
		log.Printf("Error parsing request body: %v\n", err)
		http.Error(w, "Error parsing request body", http.StatusBadRequest)
		return
	}

	if requestBody.Name == "" {
		log.Println("Received empty name field")
		http.Error(w, "name field is required", http.StatusBadRequest)
		return
	}

	res, err := db.Conn.Exec("UPDATE projects SET name = $1 WHERE id = $2", requestBody.Name, projectId)

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

	rowsAffected, err := res.RowsAffected()

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

	if rowsAffected == 0 {
		log.Printf("Project not found: %v\n", projectId)
		http.Error(w, "Project not found: "+projectId, http.StatusNotFound)
		return
	}

	log.Println("Successfully renamed project", projectId)

View on GitHub (pinned to e2d772072e)

Solutions

  1. Read the full err.Error() in the server log — it names the exact Postgres failure.
  2. Verify the database is reachable: run the same UPDATE manually via psql with the app's credentials.
  3. Check the DB user has UPDATE permission on the projects table and that migrations have created the table.
  4. Confirm DATABASE_URL / connection config and pool settings; restart or reconnect the pool if connections were dropped.
  5. Add retry/backoff around transient connection errors and health checks on startup.

Example fix

// before
res, err := db.Conn.Exec("UPDATE projects SET name = $1 WHERE id = $2", requestBody.Name, projectId)
if err != nil {
    http.Error(w, "Error updating project: "+err.Error(), http.StatusInternalServerError)
    return
}
// after
res, err := db.Conn.Exec("UPDATE projects SET name = $1 WHERE id = $2", requestBody.Name, projectId)
if err != nil {
    log.Printf("Error updating project %s: %v", projectId, err)
    if errors.Is(err, sql.ErrNoRows) || pgErr, ok := err.(*pgconn.PgError); ok && pgErr.Code == "23503" {
        http.Error(w, "Project not found", http.StatusNotFound)
        return
    }
    http.Error(w, "Error updating project", http.StatusInternalServerError)
    return
}
Defensive patterns

Strategy: try-catch

Validate before calling

// before calling: confirm the project exists and DB is reachable
const health = await fetch('/health').then(r => r.ok);
if (!health) throw new Error('Server/database unavailable, skipping rename');

Try / catch

// client
try {
  const res = await renameProject(id, name);
  if (res.status === 500) {
    console.error('Server failed to update project — check server logs / DB status');
  }
} catch (e) {
  console.error('Network/server error during rename:', e);
}

Prevention

When it happens

Trigger: Postgres connection dropped or pool exhausted; database refused the statement (e.g. permission denied on UPDATE, table missing); invalid projectId causing a driver-level conversion error; DB restarted mid-request; connection string misconfigured after deploy.

Common situations: Database container down or unreachable from the server; DB user lacking UPDATE privilege on projects; migration not run so the projects table/columns don't exist; connection pool limits hit under load; network policy blocking the DB port in staging.

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/61b6e61f6b9cdf21. Report an issue: GitHub.