{"record":{"id":"6cf1fddb26e6fc46","repo":"leptos-rs/leptos","slug":"could-not-find-key-for-index-index-at-caller","errorCode":null,"errorMessage":"could not find key for index {index:?} at {caller}","messagePattern":"could not find key for index (.+?) at (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"reactive_stores/src/store_field.rs","lineNumber":153,"sourceCode":"        let trigger = triggers.write().or_poisoned().get_or_insert(path);\n        trigger\n    }\n\n    #[track_caller]\n    fn get_trigger_unkeyed(&self, path: StorePath) -> StoreFieldTrigger {\n        let caller = std::panic::Location::caller();\n        let orig_path = path.clone();\n\n        let mut path = StorePath::with_capacity(orig_path.len());\n        for segment in &orig_path {\n            let parent_is_keyed = self.keys.contains_key(&path);\n\n            if parent_is_keyed {\n                let key = self\n                    .keys\n                    .get_key_for_index(&(path.clone(), segment.0))\n                    .unwrap_or_else(|| {\n                        panic!(\n                            \"could not find key for index {:?} at {}\",\n                            (path.clone(), segment.0),\n                            caller\n                        )\n                    });\n                path.push(key);\n            } else {\n                path.push(*segment);\n            }\n        }\n        self.get_trigger(path)\n    }\n\n    #[track_caller]\n    fn path(&self) -> impl IntoIterator<Item = StorePathSegment> {\n        iter::empty()\n    }\n","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/reactive_stores/src/store_field.rs#L135-L171","documentation":"reactive_stores keys each store field's list indices with per-index keys so fine-grained reactivity can track items across moves. get_trigger_unkeyed walks a field path and, when a parent is keyed, expects a key registered for every index segment; if the key map has no entry for (path, index) it panics. This means the store's internal key bookkeeping is out of sync with the path being resolved.","triggerScenarios":"Resolving an ArcField/field path into an unkeyed store whose parent field is keyed, when the index was never registered — e.g. mixing keyed and unkeyed access to the same store field, or accessing a list index before the store registered its keys (concurrent access during resize/clear).","commonSituations":"Using .at(index) or keyed list fields on a store while also accessing the same path unkeyed; rapid mutation (splice/clear) racing with a render pass reading triggers for old indices; custom store field code (ArcField) built against paths the store never keyed.","solutions":["Access keyed list fields consistently — do not mix keyed (.keys()/.at()) and unkeyed (.with_unkeyed()) resolution on the same path.","Ensure reads happen while the store is in a consistent state; avoid reading store fields during mutation from another thread/task.","Recreate or re-sync the store/field if you constructed ArcField paths manually; let the store derive keys itself.","Upgrade leptos/reactive_stores — this is internal bookkeeping, so a fixed version may resolve the desync."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// check index is within the keyed list before resolving an unkeyed path\nif index < store.len() && store.keys_contains_index(path, index) { /* resolve */ }","typeGuard":null,"tryCatchPattern":"std::panic::catch_unwind(|| field.get_trigger_unkeyed(path, segment, caller)).err().map(|_| default_trigger)","preventionTips":["Do not mix keyed and unkeyed access to the same store field path.","Keep reactive_stores updated to the latest patch version.","Avoid reading store triggers concurrently with structural mutations."],"tags":["leptos","reactive-stores","store-key","internal-state","panic"],"backgroundTag":"store-key-missing","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}