{"record":{"id":"b5b9a7939647bd2e","repo":"plandex-ai/plandex","slug":"error-getting-user-permissions","errorCode":null,"errorMessage":"error getting user permissions","messagePattern":"error getting user permissions","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/auth_helpers.go","lineNumber":574,"sourceCode":"\t\t\t\treturn nil\n\t\t\t}\n\n\t\t} else {\n\t\t\tlog.Println(\"user is not a member of the org\")\n\t\t\tif raiseErr {\n\t\t\t\thttp.Error(w, \"not a member of org\", http.StatusUnauthorized)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t}\n\n\t// get user permissions\n\tpermissions, err := db.GetUserPermissions(authToken.UserId, parsed.OrgId)\n\n\tif err != nil {\n\t\tlog.Printf(\"error getting user permissions: %v\\n\", err)\n\t\tif raiseErr {\n\t\t\thttp.Error(w, \"error getting user permissions\", http.StatusInternalServerError)\n\t\t}\n\t\treturn nil\n\t}\n\n\t// build the permissions map\n\tpermissionsMap := make(shared.Permissions)\n\tfor _, permission := range permissions {\n\t\tpermissionsMap[permission] = true\n\t}\n\n\tauth := &types.ServerAuth{\n\t\tAuthToken:   authToken,\n\t\tUser:        user,\n\t\tOrgId:       parsed.OrgId,\n\t\tPermissions: permissionsMap,\n\t}\n\n\t// don't send hash for org-session requests","sourceCodeStart":556,"sourceCodeEnd":592,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/auth_helpers.go#L556-L592","documentation":"After membership is confirmed, db.GetUserPermissions(authToken.UserId, parsed.OrgId) failed; the server logs 'error getting user permissions' and returns HTTP 500 when raiseErr is true. Backend failure loading the permission rows needed to build the request's permissions map.","triggerScenarios":"Authenticated, org-member request where the permissions query errors (DB down, timeout, schema mismatch in permissions/roles tables).","commonSituations":"Database outages or connection-pool exhaustion; role/permission schema migrations not applied; corrupt or missing role rows for the user-org pair.","solutions":["Check database health and inspect logs for the underlying GetUserPermissions error","Verify permissions/roles schema is up to date with the current app version","Retry the request once the DB is healthy","Check that the user's role records exist for the org and backfill if missing"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := doCall(ctx); err != nil {\n\tvar apiErr *APIError\n\tif errors.As(err, &apiErr) && apiErr.StatusCode == 500 && strings.Contains(apiErr.Message, \"user permissions\") {\n\t\treturn retryWithBackoff(ctx) // transient DB failure loading permissions\n\t}\n\treturn err\n}","preventionTips":["Monitor DB health; alert on permissions-table query failures","Keep role/permission schema migrations in sync with app version","Backfill role rows when assigning users to orgs","Retry transient failures with exponential backoff"],"tags":["database","permissions","internal-server-error"],"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"}