{"record":{"id":"9c8954828bbab528","repo":"denoland/deno","slug":"invalid-data-type-at-index-id-expected","errorCode":null,"errorMessage":"Invalid data type at index {id}, expected '{}'","messagePattern":"Invalid data type at index (.+?), expected '(.+?)'","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"libs/core/runtime/snapshot.rs","lineNumber":83,"sourceCode":"    &mut self,\n    scope: &mut v8::PinScope<'s, 'i>,\n    id: SnapshotDataId,\n  ) -> v8::Global<T>\n  where\n    v8::Local<'s, T>: TryFrom<v8::Local<'s, v8::Data>>,\n  {\n    let Some(data) = self.data.get_mut(id as usize) else {\n      panic!(\n        \"Attempted to read snapshot data out of range: {id} (of {})\",\n        self.data.len()\n      );\n    };\n    let Some(data) = data.take() else {\n      panic!(\"Attempted to read the snapshot data at index {id} twice\");\n    };\n    let local = v8::Local::new(scope, data);\n    let local = v8::Local::<T>::try_from(local).unwrap_or_else(|_| {\n      panic!(\n        \"Invalid data type at index {id}, expected '{}'\",\n        std::any::type_name::<T>()\n      )\n    });\n    v8::Global::new(scope, local)\n  }\n}\n\n#[derive(Default)]\npub struct SnapshotStoreDataStore {\n  data: Vec<v8::Global<v8::Data>>,\n}\n\nimpl SnapshotStoreDataStore {\n  pub fn register<T>(&mut self, global: v8::Global<T>) -> SnapshotDataId\n  where\n    for<'s> v8::Local<'s, v8::Data>: From<v8::Local<'s, T>>,\n  {","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/denoland/deno/blob/f7822238cab635a3a19f99f493f675fa81a7f9d8/libs/core/runtime/snapshot.rs#L65-L101","documentation":"After taking a slot, SnapshotLoadDataStore::get casts the stored v8::Data handle to the requested type T with v8::Local::<T>::try_from, and panics \"Invalid data type at index {id}, expected '{type}'\" (type spelled by std::any::type_name) when the cast fails. The snapshot holds a different v8 kind at that index than the extension now expects — the serialized representation changed between the snapshot producer and consumer.","triggerScenarios":"A deno_core or extension upgrade changed the v8 type stored for a state index (e.g. an Array where an Object used to be); a snapshot built by a different deno_core version; extensions whose snapshot state format changed without regenerating the snapshot blob.","commonSituations":"Rolling deployments mixing old snapshot artifacts with new binaries; local dev reusing a committed snapshot file after pulling dependency updates; patch releases that changed internal state shapes.","solutions":["Regenerate the startup snapshot with the binary's exact deno_core and extension versions","Treat the snapshot blob and the binary as one atomic artifact in CI (build and ship them together)","Clear any cached/committed snapshot files after dependency bumps and rebuild","Verify the version constants stamped into snapshot tooling match the linked crates"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Embed a deno_core version marker alongside the snapshot and verify at load.\nfn snapshot_matches_runtime(marker: &str) -> bool {\n  marker == env!(\"CARGO_PKG_VERSION_DENO_CORE\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never mix snapshot blobs across deno_core versions; regenerate on every bump","Store the snapshot next to the binary and invalidate it together","Add a CI step that boots one runtime from the snapshot to catch type drift before deployment"],"tags":["deno-core","snapshot","type-mismatch","version-skew","panic"],"backgroundTag":"snapshot-data-mismatch","analyzedSha":"f7822238cab635a3a19f99f493f675fa81a7f9d8","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}