{"record":{"id":"934b71b95cadc3b7","repo":"dani-garcia/vaultwarden","slug":"error-loading-group-users","errorCode":null,"errorMessage":"Error loading group users","messagePattern":"Error loading group users","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/db/models/group.rs","lineNumber":507,"sourceCode":"                    .map_res(\"Error adding user to group\")\n            }\n        }\n    }\n\n    pub async fn find_by_group(group_uuid: &GroupId, org_uuid: &OrganizationId, conn: &DbConn) -> Vec<Self> {\n        conn.run(move |conn| {\n            groups_users::table\n                .inner_join(groups::table.on(groups::uuid.eq(groups_users::groups_uuid)))\n                .inner_join(\n                    users_organizations::table.on(users_organizations::uuid\n                        .eq(groups_users::users_organizations_uuid)\n                        .and(users_organizations::org_uuid.eq(groups::organizations_uuid))),\n                )\n                .filter(groups_users::groups_uuid.eq(group_uuid))\n                .filter(groups::organizations_uuid.eq(org_uuid))\n                .select(groups_users::all_columns)\n                .load::<Self>(conn)\n                .expect(\"Error loading group users\")\n        })\n        .await\n    }\n\n    pub async fn find_by_member(member_uuid: &MembershipId, conn: &DbConn) -> Vec<Self> {\n        conn.run(move |conn| {\n            groups_users::table\n                .filter(groups_users::users_organizations_uuid.eq(member_uuid))\n                .load::<Self>(conn)\n                .expect(\"Error loading groups for user\")\n        })\n        .await\n    }\n\n    pub async fn has_access_to_collection_by_member(\n        collection_uuid: &CollectionId,\n        member_uuid: &MembershipId,\n        conn: &DbConn,","sourceCodeStart":489,"sourceCodeEnd":525,"githubUrl":"https://github.com/dani-garcia/vaultwarden/blob/cc67d644f62605cb46f4d16c4a2eed1a861cc8bb/src/db/models/group.rs#L489-L525","documentation":"This is a panic, not a returned error: inside GroupUser::find_by_group the diesel query joining groups_users, groups, and users_organizations is loaded with .expect(). It fires only when the database query itself fails - a broken/lost connection, schema mismatch between the groups_users table and the GroupUser model, or a SQL error - not when the group simply has no users (an empty vec is a valid result).","triggerScenarios":"Thrown at src/db/models/group.rs:507 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check database connectivity and that the connection pool is healthy when this panics","Verify the groups_users schema matches the GroupUser model (run migrations)","Inspect the panic message/Debug output of the diesel error for the underlying SQL failure","Replace .expect with .map_res so the failure is returned as an ApiError instead of aborting the task"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"cc67d644f62605cb46f4d16c4a2eed1a861cc8bb","analyzedAt":"2026-09-19T08:28:46.370Z","contentChangedAt":"2026-09-19T08:28:46.370Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}