{"record":{"id":"4fcba35d77e2694f","repo":"dani-garcia/vaultwarden","slug":"error-loading-folders","errorCode":null,"errorMessage":"Error loading folders","messagePattern":"Error loading folders","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/db/models/folder.rs","lineNumber":133,"sourceCode":"            folder.delete(conn).await?;\n        }\n        Ok(())\n    }\n\n    pub async fn find_by_uuid_and_user(uuid: &FolderId, user_uuid: &UserId, conn: &DbConn) -> Option<Self> {\n        conn.run(move |conn| {\n            folders::table\n                .filter(folders::uuid.eq(uuid))\n                .filter(folders::user_uuid.eq(user_uuid))\n                .first::<Self>(conn)\n                .ok()\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            folders::table.filter(folders::user_uuid.eq(user_uuid)).load::<Self>(conn).expect(\"Error loading folders\")\n        })\n        .await\n    }\n}\n\nimpl FolderCipher {\n    pub async fn save(&self, conn: &DbConn) -> EmptyResult {\n        db_run! { conn:\n            mysql {\n                diesel::insert_into(folders_ciphers::table)\n                    .values(self)\n                    .on_conflict(diesel::dsl::DuplicatedKeys)\n                    .do_nothing()\n                    .execute(conn)\n                    .map_res(\"Error adding cipher to folder\")\n            }\n            postgresql, sqlite {\n                diesel::insert_into(folders_ciphers::table)","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/dani-garcia/vaultwarden/blob/cc67d644f62605cb46f4d16c4a2eed1a861cc8bb/src/db/models/folder.rs#L115-L151","documentation":"Panic from `.expect()` on the Diesel `load` in `Folder::find_by_user`. The query listing all folders for a user failed at the database layer, aborting the task. A user with no folders returns an empty Vec normally; only actual DB errors reach this expect.","triggerScenarios":"Calling `Folder::find_by_user` while the DB is unreachable, the `folders` table or its columns are missing/renamed, or the connection errors mid-query.","commonSituations":"Schema drift after an upgrade without migrations; database restart or network blip during a sync request; SQLite file permission/lock issues; pool exhausted under heavy concurrent syncs.","solutions":["Check DB connectivity and DATABASE_URL configuration","Run pending migrations so the folders table matches the code","Read the underlying Diesel error from server logs","Fix file permissions/locks if running SQLite"],"exampleFix":"// before\n.load::<Self>(conn).expect(\"Error loading folders\")\n// after\n.load::<Self>(conn).unwrap_or_else(|e| { error!(\"load folders failed: {e}\"); Vec::new() })","handlingStrategy":"try-catch","validationCode":"// check the user exists and DB is reachable before listing folders\nif !db_ping().await { return Vec::new(); }","typeGuard":null,"tryCatchPattern":"// treat panic as service failure; pre-gate with health check\nif !conn_ready(&conn).await { return Vec::new(); }\nFolder::find_by_user(user_uuid, &conn).await","preventionTips":["Run migrations at startup on every version bump","Keep SQLite file writable by the service user","Alert on DB connection error rates","Avoid killing the DB while sync requests are in flight"],"tags":["database","panic","folders"],"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"}