dani-garcia/vaultwarden · critical
Error loading users_collections
Error message
Error loading users_collections
What it means
Panic from `expect` when `CollectionUser::find_by_organization_and_user_uuid` fails to load users_collections rows (per-user collection permissions) for a user's org memberships, joined with collections filtered by org. Query execution or deserialization failure panics; zero matching rows does not.
Solutions
- Run migrations so users_collections matches the model (including the manage column)
- Log the underlying diesel error to diagnose
- Verify DB connectivity and credentials
- Fix users_collections column set/types if manually altered
- Restore the database from a backup
Defensive patterns
Strategy: try-catch
Validate before calling
// Verify users_collections has the expected columns (SQLite)
let ok = conn.run(|c| diesel::select(diesel::dsl::sql::<diesel::sql_types::Bool>(
"SELECT EXISTS (SELECT 1 FROM pragma_table_info('users_collections') WHERE name='manage')"
)).load::<bool>(c)).await.unwrap_or(vec![false]).into_iter().next().unwrap_or(false);
assert!(ok, "users_collections.manage missing; run migrations"); Try / catch
let r = std::panic::catch_unwind(std::panic::AssertUnwindSafe(async {
CollectionUser::find_by_organization_and_user_uuid(&org_uuid, &user_uuid, &conn).await
}));
if r.is_err() { log::error!("users_collections load panicked; schema/migrations mismatch likely"); } Prevention
- Always run the migrations adding newer permission columns (manage)
- Diff DB schema against models after upgrades
- Probe DB health at startup
- Avoid partial/manual migrations
- Backup the DB before upgrading
When it happens
Trigger: Calling `find_by_organization_and_user_uuid` when DB connectivity fails, `users_collections` table schema mismatches (e.g. missing `manage` column after unmigrated upgrade), or join to collections fails at the SQL level.
Common situations: Upgrading without running the migration that added the `manage` column to users_collections; DB connection loss; manual schema edits; corrupted SQLite file.
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
- Error loading collections
- Error loading devices
- Error creating organization API Key
- Error loading ciphers
- Error loading emergency_access
AI-assisted analysis of dani-garcia/vaultwarden@cc67d644f6 (2026-09-19).
Data as JSON: /api/errors/c4ea3d3abb598e88.
Report an issue: GitHub.
Appendix: source
Thrown at src/db/models/collection.rs:681
.await
}
}
/// Database methods
impl CollectionUser {
pub async fn find_by_organization_and_user_uuid(
org_uuid: &OrganizationId,
user_uuid: &UserId,
conn: &DbConn,
) -> Vec<Self> {
conn.run(move |conn| {
users_collections::table
.filter(users_collections::user_uuid.eq(user_uuid))
.inner_join(collections::table.on(collections::uuid.eq(users_collections::collection_uuid)))
.filter(collections::org_uuid.eq(org_uuid))
.select(users_collections::all_columns)
.load::<Self>(conn)
.expect("Error loading users_collections")
})
.await
}
pub async fn find_by_organization_swap_user_uuid_with_member_uuid(
org_uuid: &OrganizationId,
conn: &DbConn,
) -> Vec<CollectionMembership> {
let col_users = conn
.run(move |conn| {
users_collections::table
.inner_join(collections::table.on(collections::uuid.eq(users_collections::collection_uuid)))
.filter(collections::org_uuid.eq(org_uuid))
.inner_join(
users_organizations::table.on(users_organizations::user_uuid.eq(users_collections::user_uuid)),
)
.filter(users_organizations::org_uuid.eq(org_uuid))
.select((View on GitHub (pinned to cc67d644f6)