{"record":{"id":"00afbdcc168b4cce","repo":"tracel-ai/burn","slug":"expected-array-of-length-got","errorCode":null,"errorMessage":"Expected array of length {}, got {}","messagePattern":"Expected array of length (.+?), got (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-core/src/module/param/primitive.rs","lineNumber":192,"sourceCode":"            let index_str = alloc::format!(\"{}\", i);\n            visitor.enter_module(&index_str, \"Array\");\n            module.visit(visitor);\n            visitor.exit_module(&index_str, \"Array\");\n        }\n    }\n\n    fn map<M: ModuleMapper>(self, mapper: &mut M) -> Self {\n        let mut result = Vec::with_capacity(N);\n        for (i, module) in IntoIterator::into_iter(self).enumerate() {\n            let index_str = alloc::format!(\"{}\", i);\n            mapper.enter_module(&index_str, \"Array\");\n            let mapped = module.map(mapper);\n            mapper.exit_module(&index_str, \"Array\");\n            result.push(mapped);\n        }\n        result\n            .try_into()\n            .unwrap_or_else(|v: Vec<T>| panic!(\"Expected array of length {}, got {}\", N, v.len()))\n    }\n\n    fn to_device(self, device: &Device) -> Self {\n        self.map(|module| module.to_device(device))\n    }\n\n    fn fork(self, device: &Device) -> Self {\n        self.map(|module| module.fork(device))\n    }\n}\n\nimpl<const N: usize, T: ModuleDisplay> ModuleDisplayDefault for [T; N] {\n    fn content(&self, content: Content) -> Option<Content> {\n        self.iter()\n            .enumerate()\n            .fold(content, |acc, (i, module)| {\n                let index = format!(\"{i}\");\n                acc.add(&index, module)","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-core/src/module/param/primitive.rs#L174-L210","documentation":"Length-mismatch guard when visiting/mapping a fixed-size `Module<const N>` array: code expects the module's element count to equal the compile-time `N`, and the formatted message reports the expected N versus the actual runtime length. It fires when a deserialized or manually constructed container has a different number of elements than the static array type declares — the input at fault is the wrongly sized module data.","triggerScenarios":"Thrown at crates/burn-core/src/module/param/primitive.rs:192 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the record/state being loaded into the array contains exactly N elements matching the const generic.","When loading checkpoints from a changed model, migrate or reshape the parameter list to N before `map`/`to_device`/`fork`.","Add a pre-load check comparing element count with N to fail with a clearer message."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}