{"record":{"id":"beea01a4061e4108","repo":"denoland/deno","slug":"invalid-module-type","errorCode":null,"errorMessage":"invalid module type","messagePattern":"invalid module type","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"libs/eszip/v2.rs","lineNumber":964,"sourceCode":"\n        let wakers = {\n          let mut modules = modules.lock().unwrap();\n          let module = modules.get_mut(&specifier).expect(\"module not found\");\n          match module {\n            EszipV2Module::Module { source, .. } => {\n              let slot = std::mem::replace(\n                source,\n                EszipV2SourceSlot::Ready(Arc::from(\n                  source_bytes.into_content(),\n                )),\n              );\n\n              match slot {\n                EszipV2SourceSlot::Pending { wakers, .. } => wakers,\n                _ => panic!(\"already populated source slot\"),\n              }\n            }\n            _ => panic!(\"invalid module type\"),\n          }\n        };\n        for w in wakers {\n          w.wake();\n        }\n      }\n\n      let source_maps_len = read_u32(&mut reader).await? as usize;\n      let mut read = 0;\n\n      while read < source_maps_len {\n        let (length, specifier) = source_map_offsets\n          .remove(&read)\n          .ok_or(ParseError::InvalidV2SourceOffset(read))?;\n\n        let source_map_bytes =\n          Section::read_with_size(&mut reader, options, length).await?;\n        if !source_map_bytes.is_checksum_valid() {","sourceCodeStart":946,"sourceCodeEnd":982,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/libs/eszip/v2.rs#L946-L982","documentation":"In the same parse loop, after resolving a source offset to a specifier, the module must be EszipV2Module::Module to receive source bytes; hitting the catch-all arm panics \"invalid module type\". Well-formed writers never emit source byte sections for Redirect entries (redirects have no source), so this means the archive's sources section references a redirect module — a structural inconsistency only a corrupted or mis-generated file can contain.","triggerScenarios":"Parsing an eszip v2 whose sources section contains an entry whose specifier maps to a Redirect module; files written by buggy or incompatible custom eszip producers; corruption that shifts offsets so source bytes are attributed to the wrong specifier.","commonSituations":"Compiled artifacts transferred without integrity checks; eszips produced by patched/forked tooling; cross-version artifact processing pipelines.","solutions":["Rebuild the artifact with a current, unmodified toolchain","Verify transport integrity (checksums, re-download) before parsing","Isolate the failure with EszipV2::parse on the raw bytes to rule out upstream I/O corruption","Capture the artifact and report the structural bug to the eszip maintainers"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Same pre-flight: confirm magic and integrity metadata before parse.\nassert!(EszipV2::has_magic(&bytes[..8]), \"not an eszip v2 artifact\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not post-process eszip files with external tools unless they round-trip validate","Re-download or rebuild artifacts that fail integrity checks","Pin one eszip version across build and runtime environments"],"tags":["eszip","corruption","parsing","redirect","v2","panic"],"backgroundTag":"corrupted-eszip-archive","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T04:17:50.494Z"}