{"record":{"id":"c3c457163662c33c","repo":"loco-rs/loco","slug":"memory-service-must-build-with-success","errorCode":null,"errorMessage":"memory service must build with success","messagePattern":"memory service must build with success","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/storage/drivers/mem.rs","lineNumber":21,"sourceCode":"use super::StoreDriver;\nuse crate::storage::drivers::opendal_adapter::OpendalAdapter;\n\n/// Create new in-memory storage.\n///\n/// # Examples\n///```\n/// use loco_rs::storage::drivers::mem;\n/// let mem_storage = mem::new();\n/// ```\n///\n/// # Panics\n///\n/// Panics if the memory service built failed.\n#[must_use]\npub fn new() -> Box<dyn StoreDriver> {\n    // opendal 0.58: Operator::new returns a finished Operator (no .finish()).\n    Box::new(OpendalAdapter::new(\n        Operator::new(Memory::default()).expect(\"memory service must build with success\"),\n    ))\n}\n","sourceCodeStart":3,"sourceCodeEnd":24,"githubUrl":"https://github.com/loco-rs/loco/blob/23639d1e360dbc618073642b507d6f8664adbaff/src/storage/drivers/mem.rs#L3-L24","documentation":"The in-memory storage driver constructs an OpenDAL `Operator` over a default `Memory` service. Because `Memory::default()` has no configurable fields that can be wrong, this `expect` can essentially only fire if the OpenDAL builder itself fails internally (library bug or version mismatch). It is an invariant guard: memory storage must always build.","triggerScenarios":"Calling `loco_rs::storage::drivers::mem::new()` with an opendal crate version mismatch in the dependency tree (e.g. two opendal major versions), or an opendal internal builder error on `Memory::default()`.","commonSituations":"Cargo dependency resolution pulling an incompatible opendal after an upgrade; vendored/patched builds where the memory service feature is disabled or broken.","solutions":["Run `cargo update -p opendal` / check `cargo tree -i opendal` to ensure a single compatible opendal version matching loco's (0.58-style API)","Restore the default loco dependency versions for opendal if they were patched","Report an upstream opendal bug if the memory builder fails with default settings"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Ensure a single compatible opendal in the tree before relying on drivers\n// $ cargo tree -i opendal  # must show exactly one version\nstd::process::Command::new(\"cargo\")\n    .args([\"tree\", \"-i\", \"opendal\"])\n    .status()?;","typeGuard":null,"tryCatchPattern":"// Guard the construction in tests/tools\nlet driver = std::panic::catch_unwind(loco_rs::storage::drivers::mem::new)\n    .map_err(|_| anyhow::anyhow!(\"memory storage driver failed; check opendal version\"))?;","preventionTips":["Pin opendal to the version loco uses; avoid git patches on opendal","Run `cargo tree -i opendal` in CI to catch duplicate versions","Upgrade loco and opendal together"],"tags":["rust","storage","opendal","memory","panic"],"backgroundTag":"internal-invariant-violation","analyzedSha":"23639d1e360dbc618073642b507d6f8664adbaff","analyzedAt":"2026-09-12T01:47:20.769Z","contentChangedAt":"2026-09-12T01:47:20.769Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}