dani-garcia/vaultwarden · error

Error loading user collection groups

Error message

Error loading user collection groups

What it means

Panic from `.expect()` on the Diesel query in `CollectionGroup::find_by_user`, joining users_organizations, groups and collections_groups to list a user's collection-group memberships. A database-level failure aborts the call. Like its sibling queries, a valid-but-unmapped user simply returns an empty Vec; only real DB errors reach this expect.

Solutions

  1. Run all pending migrations so users_organizations, groups and collections_groups schemas match the code
  2. Verify DB connectivity and credentials in DATABASE_URL
  3. Check server logs for the underlying Diesel error behind the panic
  4. Resolve SQLite lock/permission issues or recycle the connection pool if connection-related

Example fix

// before
.load::<Self>(conn).expect("Error loading user collection groups")
// after
.load::<Self>(conn).unwrap_or_else(|e| { error!("load user collection groups failed: {e}"); Vec::new() })
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure user exists in users_organizations before membership lookups
let is_member = UsersOrganizations::find_by_user_and_org(user, org, conn).await.is_some();

Try / catch

// health-gate the multi-join query
if !db_ok().await { return Vec::new(); }
CollectionGroup::find_by_user(user_uuid, conn).await

Prevention

When it happens

Trigger: Calling `CollectionGroup::find_by_user` when the DB is unreachable, joined tables lack expected columns (e.g. collections_groups missing), or the connection drops mid-query.

Common situations: Upgrade without migrations on an old schema; database outage or restart during sync; SQLite file lock/permission problems; connection-pool exhaustion under load.

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


AI-assisted analysis of dani-garcia/vaultwarden@cc67d644f6 (2026-09-19). Data as JSON: /api/errors/85b13a6db4772dcb. Report an issue: GitHub.

Appendix: source

Thrown at src/db/models/group.rs:389

            collections_groups::table
                .inner_join(groups_users::table.on(groups_users::groups_uuid.eq(collections_groups::groups_uuid)))
                .inner_join(
                    users_organizations::table.on(users_organizations::uuid.eq(groups_users::users_organizations_uuid)),
                )
                .inner_join(
                    groups::table.on(groups::uuid
                        .eq(collections_groups::groups_uuid)
                        .and(groups::organizations_uuid.eq(users_organizations::org_uuid))),
                )
                .inner_join(
                    collections::table.on(collections::uuid
                        .eq(collections_groups::collections_uuid)
                        .and(collections::org_uuid.eq(groups::organizations_uuid))),
                )
                .filter(users_organizations::user_uuid.eq(user_uuid))
                .select(collections_groups::all_columns)
                .load::<Self>(conn)
                .expect("Error loading user collection groups")
        })
        .await
    }

    pub async fn find_by_collection(collection_uuid: &CollectionId, conn: &DbConn) -> Vec<Self> {
        conn.run(move |conn| {
            collections_groups::table
                .filter(collections_groups::collections_uuid.eq(collection_uuid))
                .inner_join(collections::table.on(collections::uuid.eq(collections_groups::collections_uuid)))
                .inner_join(
                    groups::table.on(groups::uuid
                        .eq(collections_groups::groups_uuid)
                        .and(groups::organizations_uuid.eq(collections::org_uuid))),
                )
                .select(collections_groups::all_columns)
                .load::<Self>(conn)
                .expect("Error loading collection groups")
        })

View on GitHub (pinned to cc67d644f6)