{"record":{"id":"4fcf8906e859eab7","repo":"plandex-ai/plandex","slug":"error-creating-project","errorCode":null,"errorMessage":"Error creating project: ","messagePattern":"Error creating project: ","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/projects.go","lineNumber":63,"sourceCode":"\t}\n\n\tvar projectId string\n\terr = db.WithTx(r.Context(), \"create project\", func(tx *sqlx.Tx) error {\n\t\tvar err error\n\n\t\tprojectId, err = db.CreateProject(auth.OrgId, requestBody.Name, tx)\n\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error creating project: %v\\n\", err)\n\t\t\treturn fmt.Errorf(\"error creating project: %v\", err)\n\t\t}\n\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\tlog.Printf(\"Error creating project: %v\\n\", err)\n\t\thttp.Error(w, \"Error creating project: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tresp := shared.CreateProjectResponse{\n\t\tId: projectId,\n\t}\n\n\tbytes, err := json.Marshal(resp)\n\n\tif err != nil {\n\t\tlog.Printf(\"Error marshalling response: %v\\n\", err)\n\t\thttp.Error(w, \"Error marshalling response: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Write(bytes)\n\n\tlog.Println(\"Successfully created project\", projectId)","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/projects.go#L45-L81","documentation":"The handler wraps any failure from db.CreateProject inside a db.WithTx transaction and returns it as an HTTP 500 with the underlying error text appended. This means the project INSERT failed or the transaction rolled back — a server-side problem, not a client input problem.","triggerScenarios":"POST to the create-project endpoint with a valid non-empty name, but db.CreateProject errors: Postgres connection failure, projects table missing/migrated, unique constraint violation, context cancellation mid-tx, or WithTx begin/commit failure.","commonSituations":"Postgres is down or unreachable (wrong DB_HOST/credentials in env); schema migrations not applied so the projects table or a column is missing; duplicate project name if a unique constraint exists; client disconnecting cancels r.Context() and aborts the transaction.","solutions":["Read the server log line 'Error creating project: ...' — the appended err.Error() tells the real cause (connection refused, relation does not exist, constraint violation).","Verify Postgres is reachable and credentials in the server env are correct (test with psql).","Run pending database migrations so the projects table exists with the expected columns.","If the cause is a constraint violation (duplicate), use a different project name or drop/relax the constraint.","Check for context cancellation (client timeout/disconnect) and retry with a longer timeout."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"resp, err := client.CreateProject(ctx, name)\nif err != nil && strings.Contains(err.Error(), \"Error creating project:\") {\n\t// server-side DB failure; check status 500\n}","typeGuard":null,"tryCatchPattern":"resp, err := client.CreateProject(ctx, name)\nif err != nil {\n\tvar apiErr *APIError\n\tif errors.As(err, &apiErr) && apiErr.StatusCode == 500 {\n\t\tlog.Printf(\"server failed to create project (transient/DB issue): %v\", apiErr)\n\t\t// surface to user as 'try again' / check server health\n\t}\n\treturn err\n}","preventionTips":["Monitor Postgres health and migrations before deploys.","Use unique-but-reasonable project names if constraints exist.","Set reasonable client timeouts so context cancellation inside the transaction is rare.","Alert on the server log pattern 'Error creating project:'.","Ensure the server closes rows/transactions to avoid pool exhaustion."],"tags":["database","postgres","go","http-500"],"backgroundTag":"database-insert-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"}