plandex-ai/plandex · error
Error creating project:
Error message
Error creating project:
What it means
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.
Source
Thrown at app/server/handlers/projects.go:63
}
var projectId string
err = db.WithTx(r.Context(), "create project", func(tx *sqlx.Tx) error {
var err error
projectId, err = db.CreateProject(auth.OrgId, requestBody.Name, tx)
if err != nil {
log.Printf("Error creating project: %v\n", err)
return fmt.Errorf("error creating project: %v", err)
}
return nil
})
if err != nil {
log.Printf("Error creating project: %v\n", err)
http.Error(w, "Error creating project: "+err.Error(), http.StatusInternalServerError)
return
}
resp := shared.CreateProjectResponse{
Id: projectId,
}
bytes, err := json.Marshal(resp)
if err != nil {
log.Printf("Error marshalling response: %v\n", err)
http.Error(w, "Error marshalling response: "+err.Error(), http.StatusInternalServerError)
return
}
w.Write(bytes)
log.Println("Successfully created project", projectId)View on GitHub (pinned to e2d772072e)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
resp, err := client.CreateProject(ctx, name)
if err != nil && strings.Contains(err.Error(), "Error creating project:") {
// server-side DB failure; check status 500
} Try / catch
resp, err := client.CreateProject(ctx, name)
if err != nil {
var apiErr *APIError
if errors.As(err, &apiErr) && apiErr.StatusCode == 500 {
log.Printf("server failed to create project (transient/DB issue): %v", apiErr)
// surface to user as 'try again' / check server health
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Error getting contexts:
- error adding plan context tokens: %v
- error adding org member: %v
- error listing org roles: %v
- error adding org user: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/4fcf8906e859eab7.
Report an issue: GitHub.