{"record":{"id":"a0eb795ae312ec2d","repo":"plandex-ai/plandex","slug":"error-listing-users-err-error","errorCode":null,"errorMessage":"Error listing users: {err.Error()}","messagePattern":"Error listing users: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/users.go","lineNumber":54,"sourceCode":"\tif err != nil {\n\t\tlog.Printf(\"Error getting org: %v\\n\", err)\n\t\thttp.Error(w, \"Error getting org: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif org.IsTrial {\n\t\twriteApiError(w, shared.ApiError{\n\t\t\tType:   shared.ApiErrorTypeTrialActionNotAllowed,\n\t\t\tStatus: http.StatusForbidden,\n\t\t\tMsg:    \"Trial user can't list users\",\n\t\t})\n\t\treturn\n\t}\n\n\tusers, err := db.ListUsers(auth.OrgId)\n\tif err != nil {\n\t\tlog.Println(\"Error listing users: \", err)\n\t\thttp.Error(w, \"Error listing users: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tapiUsers := make([]*shared.User, 0, len(users))\n\tfor _, user := range users {\n\t\tapiUsers = append(apiUsers, user.ToApi())\n\t}\n\n\torgUsers, err := db.ListOrgUsers(auth.OrgId)\n\tif err != nil {\n\t\tlog.Println(\"Error listing org users: \", err)\n\t\thttp.Error(w, \"Error listing org users: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\torgUsersByUserId := make(map[string]*shared.OrgUser)\n\tfor _, orgUser := range orgUsers {\n\t\torgUsersByUserId[orgUser.UserId] = orgUser.ToApi()","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/users.go#L36-L72","documentation":"After org checks pass, ListUsersHandler calls db.ListUsers(auth.OrgId) to enumerate all users belonging to the org. A query failure is returned as 500 with the raw error text: 'Error listing users: <err>'.","triggerScenarios":"GET users list when the users query fails: DB unreachable, malformed join/query due to schema drift, users table locked, or context timeout during a large org listing.","commonSituations":"Migration mismatch between users table schema and the User struct tags; database connection saturation; slow query timing out for very large orgs.","solutions":["Check the raw DB error in the response body or server log","Verify the users table schema matches the User struct (run migrations)","Check DB connection pool saturation and slow-query logs","Retry; if timeouts recur for big orgs, investigate query performance/indexes"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await api.listUsers();\n} catch (e) {\n  if (e.status === 500 && /Error listing users/.test(e.message)) {\n    await backoffRetry(() => api.listUsers(), 3);\n  } else throw e;\n}","preventionTips":["Apply user-table migrations before server rollout","Index users by org_id to keep large-org listings fast","Watch slow-query and connection-pool metrics","Retry transient 5xx with backoff"],"tags":["database","http-500","users"],"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"}