{"record":{"id":"839d434fd0832298","repo":"spacedriveapp/spacedrive","slug":"library-not-initialized","errorCode":null,"errorMessage":"Library {} not initialized","messagePattern":"Library (.+?) not initialized","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"core/src/service/sidecar_manager.rs","lineNumber":96,"sourceCode":"\t\t);\n\t\tOk(())\n\t}\n\n\t/// Remove path builder for a library\n\tpub async fn deinit_library(&self, library_id: &Uuid) {\n\t\tlet mut builders = self.path_builders.write().await;\n\t\tbuilders.remove(library_id);\n\n\t\tinfo!(\"Deinitialized sidecar manager for library {}\", library_id);\n\t}\n\n\t/// Get path builder for a library\n\tasync fn get_path_builder(&self, library_id: &Uuid) -> Result<Arc<SidecarPathBuilder>> {\n\t\tlet builders = self.path_builders.read().await;\n\t\tbuilders\n\t\t\t.get(library_id)\n\t\t\t.cloned()\n\t\t\t.ok_or_else(|| anyhow::anyhow!(\"Library {} not initialized\", library_id))\n\t}\n\n\t/// Compute sidecar path\n\tpub async fn compute_path(\n\t\t&self,\n\t\tlibrary_id: &Uuid,\n\t\tcontent_uuid: &Uuid,\n\t\tkind: &SidecarKind,\n\t\tvariant: &SidecarVariant,\n\t\tformat: &SidecarFormat,\n\t) -> Result<SidecarPath> {\n\t\tlet builder = self.get_path_builder(library_id).await?;\n\t\tOk(builder.build(content_uuid, kind, variant, format))\n\t}\n\n\t/// Check if a sidecar exists in the filesystem\n\tpub async fn exists(\n\t\t&self,","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/core/src/service/sidecar_manager.rs#L78-L114","documentation":"SidecarManager::get_path_builder found no SidecarPathBuilder for the library in its path_builders map. The manager is initialized per library; any compute_path, store, or availability call for an uninitialized or already deinitialized library hits this error. The library_id in the message names the missing entry.","triggerScenarios":"Calling sidecar path computation before initialize ran for that library; using the manager after deinitialize_library during library close; a stale SidecarManager handle surviving a library reopen cycle.","commonSituations":"Startup ordering where scan or thumbnail jobs touch sidecars before the library finishes opening; shutdown races during library close or deletion.","solutions":["Initialize the sidecar manager for the library (register its path builder) before dispatching sidecar work","Only schedule sidecar jobs from contexts that hold an open, fully initialized library","During library close, stop sidecar producers before deinitialize so late callers get a clean cancellation"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Track initialized libraries and route sidecar calls through it\nif !sidecar_manager.is_initialized(&library_id).await {\n    sidecar_manager.initialize(&library).await?;\n}\nsidecar_manager.compute_path(&library_id, ...).await?;","typeGuard":"async fn sidecar_ready(mgr: &SidecarManager, library_id: &Uuid) -> bool {\n    mgr.path_builders_read().await.contains_key(library_id)\n}","tryCatchPattern":"match sidecar_manager.compute_path(&library_id, content_uuid, kind, variant, format).await {\n    Err(e) if e.to_string().contains(\"not initialized\") => {\n        // re-initialize the manager for the library and retry once\n    }\n    other => other,\n}","preventionTips":["Initialize the sidecar manager inside library open, before scheduling any sidecar work","Derive sidecar calls from an open library handle so lifecycle is implicit","Stop sidecar producers before deinitializing at library close"],"tags":["sidecar","lifecycle","initialization","library"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}