{"record":{"id":"9670e22661613ac0","repo":"dani-garcia/vaultwarden","slug":"error-loading-collection-groups","errorCode":null,"errorMessage":"Error loading collection groups","messagePattern":"Error loading collection groups","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/db/models/group.rs","lineNumber":364,"sourceCode":"                    .map_res(\"Error adding group to collection\")\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            collections_groups::table\n                .inner_join(groups::table.on(groups::uuid.eq(collections_groups::groups_uuid)))\n                .inner_join(\n                    collections::table.on(collections::uuid\n                        .eq(collections_groups::collections_uuid)\n                        .and(collections::org_uuid.eq(groups::organizations_uuid))),\n                )\n                .filter(collections_groups::groups_uuid.eq(group_uuid))\n                .filter(collections::org_uuid.eq(org_uuid))\n                .select(collections_groups::all_columns)\n                .load::<Self>(conn)\n                .expect(\"Error loading collection groups\")\n        })\n        .await\n    }\n\n    pub async fn find_by_user(user_uuid: &UserId, conn: &DbConn) -> Vec<Self> {\n        conn.run(move |conn| {\n            collections_groups::table\n                .inner_join(groups_users::table.on(groups_users::groups_uuid.eq(collections_groups::groups_uuid)))\n                .inner_join(\n                    users_organizations::table.on(users_organizations::uuid.eq(groups_users::users_organizations_uuid)),\n                )\n                .inner_join(\n                    groups::table.on(groups::uuid\n                        .eq(collections_groups::groups_uuid)\n                        .and(groups::organizations_uuid.eq(users_organizations::org_uuid))),\n                )\n                .inner_join(\n                    collections::table.on(collections::uuid","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/dani-garcia/vaultwarden/blob/cc67d644f62605cb46f4d16c4a2eed1a861cc8bb/src/db/models/group.rs#L346-L382","documentation":"Panic from `.expect()` on the Diesel query in `CollectionGroup::find_by_group`, joining collections_groups with collections to fetch a group's collection assignments scoped to an org. A database failure aborts the call. It depends on three tables (collections_groups, collections, groups), so any schema drift among them can trigger it.","triggerScenarios":"Calling `CollectionGroup::find_by_group` with an unreachable DB, missing collections_groups table/columns, or a join clause the backend rejects.","commonSituations":"Pre-collections-groups schema after upgrading without migrations; DB connection dropped mid-request; SQLite locking; switching database backends with un-migrated schema.","solutions":["Apply all pending migrations (collections_groups table present with expected columns)","Check DB connectivity and DATABASE_URL configuration","Inspect server logs for the underlying Diesel error","Verify the group UUID and org UUID reference existing rows if data integrity is in question"],"exampleFix":"// before\n.load::<Self>(conn).expect(\"Error loading collection groups\")\n// after\n.load::<Self>(conn).unwrap_or_else(|e| { error!(\"load collection groups failed: {e}\"); Vec::new() })","handlingStrategy":"try-catch","validationCode":"// verify collections_groups table is present\n// SELECT 1 FROM collections_groups LIMIT 1;","typeGuard":null,"tryCatchPattern":"// schema and health gate before joined lookups\nif !db_ok().await || !table_exists(\"collections_groups\").await { return Vec::new(); }\nCollectionGroup::find_by_group(group_uuid, org_uuid, conn).await","preventionTips":["Apply collections/groups migrations as a unit","Avoid manual schema edits on join tables","Monitor DB during org-admin operations","Validate UUIDs reference existing rows before deep joins"],"tags":["database","panic","collections","groups"],"backgroundTag":"database-query-failed","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"}