{"record":{"id":"61b6e61f6b9cdf21","repo":"plandex-ai/plandex","slug":"error-updating-project","errorCode":null,"errorMessage":"Error updating project: ","messagePattern":"Error updating project: ","errorType":"http","errorClass":null,"httpStatus":500,"severity":"critical","filePath":"app/server/handlers/projects.go","lineNumber":208,"sourceCode":"\n\tvar requestBody shared.RenameProjectRequest\n\tif err := json.Unmarshal(body, &requestBody); err != nil {\n\t\tlog.Printf(\"Error parsing request body: %v\\n\", err)\n\t\thttp.Error(w, \"Error parsing request body\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif requestBody.Name == \"\" {\n\t\tlog.Println(\"Received empty name field\")\n\t\thttp.Error(w, \"name field is required\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tres, err := db.Conn.Exec(\"UPDATE projects SET name = $1 WHERE id = $2\", requestBody.Name, projectId)\n\n\tif err != nil {\n\t\tlog.Printf(\"Error updating project: %v\\n\", err)\n\t\thttp.Error(w, \"Error updating project: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\trowsAffected, err := res.RowsAffected()\n\n\tif err != nil {\n\t\tlog.Printf(\"Error getting rows affected: %v\\n\", err)\n\t\thttp.Error(w, \"Error getting rows affected: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif rowsAffected == 0 {\n\t\tlog.Printf(\"Project not found: %v\\n\", projectId)\n\t\thttp.Error(w, \"Project not found: \"+projectId, http.StatusNotFound)\n\t\treturn\n\t}\n\n\tlog.Println(\"Successfully renamed project\", projectId)","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/projects.go#L190-L226","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the full err.Error() in the server log — it names the exact Postgres failure.","Verify the database is reachable: run the same UPDATE manually via psql with the app's credentials.","Check the DB user has UPDATE permission on the projects table and that migrations have created the table.","Confirm DATABASE_URL / connection config and pool settings; restart or reconnect the pool if connections were dropped.","Add retry/backoff around transient connection errors and health checks on startup."],"exampleFix":"// before\nres, err := db.Conn.Exec(\"UPDATE projects SET name = $1 WHERE id = $2\", requestBody.Name, projectId)\nif err != nil {\n    http.Error(w, \"Error updating project: \"+err.Error(), http.StatusInternalServerError)\n    return\n}\n// after\nres, err := db.Conn.Exec(\"UPDATE projects SET name = $1 WHERE id = $2\", requestBody.Name, projectId)\nif err != nil {\n    log.Printf(\"Error updating project %s: %v\", projectId, err)\n    if errors.Is(err, sql.ErrNoRows) || pgErr, ok := err.(*pgconn.PgError); ok && pgErr.Code == \"23503\" {\n        http.Error(w, \"Project not found\", http.StatusNotFound)\n        return\n    }\n    http.Error(w, \"Error updating project\", http.StatusInternalServerError)\n    return\n}","handlingStrategy":"try-catch","validationCode":"// before calling: confirm the project exists and DB is reachable\nconst health = await fetch('/health').then(r => r.ok);\nif (!health) throw new Error('Server/database unavailable, skipping rename');","typeGuard":null,"tryCatchPattern":"// client\ntry {\n  const res = await renameProject(id, name);\n  if (res.status === 500) {\n    console.error('Server failed to update project — check server logs / DB status');\n  }\n} catch (e) {\n  console.error('Network/server error during rename:', e);\n}","preventionTips":["Monitor database health and connection pool saturation.","Run migrations before deploys so the schema always matches the code.","Grant the app's DB user only the privileges it needs — and verify UPDATE is among them.","Add retry/backoff for transient DB errors in the handler."],"tags":["database","postgres","http-500","sql"],"backgroundTag":"database-query-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"}