plandex-ai/plandex · error
Error listing org roles:
Error message
Error listing org roles:
What it means
db.ListOrgRoles(auth.OrgId) failed while querying org_roles for the org, so the handler returns HTTP 500 with the wrapped error. The org exists and the user has permission, but the roles query itself errored.
Solutions
- Read the underlying error from server logs (logged immediately before the 500)
- Run pending database migrations to ensure org_roles schema is current
- Verify DB connectivity and retry after transient outages
- Check for scan errors caused by manually modified role rows
Defensive patterns
Strategy: retry
Validate before calling
// client: preflight DB-backed endpoints lightly; mostly ensure org membership first const org = await getCurrentOrg(); if (!org || org.isTrial) return; // trial orgs are rejected earlier
Try / catch
try {
const roles = await listOrgRoles();
} catch (e) {
if (e.status === 500) { await backoffRetry(e, { attempts: 3 }); } // transient DB errors
else throw e;
} Prevention
- Apply DB migrations before serving traffic
- Add bounded retry with backoff for 500s on read endpoints
- Watch for scan/schema errors after server upgrades
- Avoid manual edits to org_roles rows
When it happens
Trigger: Calling the list-org-roles endpoint when the org_roles table is missing or schema-mismatched, the DB connection drops mid-query, or rows contain data that fails to scan into the OrgRole model.
Common situations: Unapplied migrations leaving the org_roles table absent, malformed/corrupt role rows after manual edits, transient Postgres restarts, schema drift after upgrading the server.
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
- Error creating branch:
- Error creating email verification:
- Error creating project:
- Error creating sign in code:
- Error deleting draft plans:
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/801c773750244f87.
Report an issue: GitHub.
Appendix: source
Thrown at app/server/handlers/orgs.go:237
writeApiError(w, shared.ApiError{
Type: shared.ApiErrorTypeTrialActionNotAllowed,
Status: http.StatusForbidden,
Msg: "Trial user can't list org roles",
})
return
}
if !auth.HasPermission(shared.PermissionListOrgRoles) {
log.Println("User cannot list org roles")
http.Error(w, "User cannot list org roles", http.StatusForbidden)
return
}
roles, err := db.ListOrgRoles(auth.OrgId)
if err != nil {
log.Printf("Error listing org roles: %v\n", err)
http.Error(w, "Error listing org roles: "+err.Error(), http.StatusInternalServerError)
return
}
var apiRoles []*shared.OrgRole
for _, role := range roles {
apiRoles = append(apiRoles, role.ToApi())
}
bytes, err := json.Marshal(apiRoles)
if err != nil {
log.Printf("Error marshalling response: %v\n", err)
http.Error(w, "Error marshalling response: "+err.Error(), http.StatusInternalServerError)
return
}
log.Println("Successfully listed org roles")
View on GitHub (pinned to e2d772072e)