{"record":{"id":"fa73f6e7f38daca6","repo":"denoland/deno","slug":"missing-index","errorCode":null,"errorMessage":"missing index '{}'","messagePattern":"missing index '(.+?)'","errorType":"exception","errorClass":"ParseError","httpStatus":null,"severity":"error","filePath":"libs/eszip/v2.rs","lineNumber":1785,"sourceCode":"  let mut pkg_index_to_pkg_id = HashMap::with_capacity(packages.len());\n  for (i, pkg) in packages.iter().enumerate() {\n    let id = NpmPackageId::from_serialized(&pkg.name).map_err(|err| {\n      ParseError::InvalidV2NpmPackage(pkg.name.clone(), err.into())\n    })?;\n    pkg_index_to_pkg_id.insert(EszipNpmPackageIndex(i as u32), id);\n  }\n  let mut final_packages = Vec::with_capacity(packages.len());\n  for (i, pkg) in packages.into_iter().enumerate() {\n    let eszip_id = EszipNpmPackageIndex(i as u32);\n    let id = pkg_index_to_pkg_id.get(&eszip_id).unwrap();\n    let mut dependencies = HashMap::with_capacity(pkg.dependencies.len());\n    for (key, pkg_index) in pkg.dependencies {\n      let id = match pkg_index_to_pkg_id.get(&pkg_index) {\n        Some(id) => id,\n        None => {\n          return Err(ParseError::InvalidV2NpmPackage(\n            pkg.name,\n            anyhow::anyhow!(\"missing index '{}'\", pkg_index.0),\n          ));\n        }\n      };\n      dependencies.insert(StackString::from_string(key), id.clone());\n    }\n    final_packages.push(SerializedNpmResolutionSnapshotPackage {\n      id: id.clone(),\n      system: Default::default(),\n      dist: Default::default(),\n      dependencies,\n      optional_dependencies: Default::default(),\n      extra: Default::default(),\n      is_deprecated: false,\n      has_bin: false,\n      has_scripts: false,\n      optional_peer_dependencies: Default::default(),\n    });\n  }","sourceCodeStart":1767,"sourceCodeEnd":1803,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/libs/eszip/v2.rs#L1767-L1803","documentation":"On the parsing side of eszip v2, each embedded npm package lists dependencies as indexes into the package table. pkg_index_to_pkg_id maps those indexes to ids; a dependency pointing at an index with no corresponding package yields ParseError::InvalidV2NpmPackage with cause \"missing index '<N>'\". The archive's npm package table is internally inconsistent — a corrupted or wrongly-generated eszip.","triggerScenarios":"Feeding eszip v2 a truncated or bit-flipped archive where a dependency index exceeds the package count; an eszip written by a buggy/older writer that dropped a package but left references; hand-crafted or patched archives with mismatched tables.","commonSituations":"Compiled binaries corrupted in transfer (partial upload, interrupted docker build layer); artifacts produced by mismatched deno/eszip crate versions in custom pipelines; checksum-unverified downloads of compile output.","solutions":["Regenerate the eszip/compiled binary from source with a current Deno version","Verify integrity of the artifact in transit (sha256 on both ends) and re-transfer if it differs","If you build tooling on eszip, ensure writer and reader use the same crate version so tables are written consistently","If corruption recurs on clean builds, reduce to a repro and report to denoland"],"exampleFix":"# before\ndeno run ./app.corrupted  # eszip parse: missing index '3'\n\n# after\nsha256sum ./app # compare against build-time checksum; rebuild on mismatch\ndeno compile -o ./app src/mod.ts && deno run ./app","handlingStrategy":"try-catch","validationCode":"// eszip consumers: verify integrity before parsing\nconst bytes = await Deno.readFile(archivePath);\nconst digest = await crypto.subtle.digest(\"SHA-256\", bytes);\nif (expectedSha && toHex(digest) !== expectedSha) throw new Error(\"eszip integrity check failed\");\n// then hand `bytes` to the parser","typeGuard":null,"tryCatchPattern":"// Rust, when parsing eszip v2\nmatch eszip::EszipV2::parse(bytes) {\n    Err(ParseError::InvalidV2NpmPackage(name, e)) if e.to_string().contains(\"missing index\") => {\n        // archive is inconsistent: re-encode from source, do not retry parse\n        return Err(anyhow!(\"corrupt eszip: package {name} has dangling index; rebuild required\"));\n    }\n    r => r?,\n}","preventionTips":["Checksum compiled/eszip artifacts at build time and verify before every parse","Use the same deno/eszip crate version for writing and reading","Don't hand-modify or partially download eszip archives"],"tags":["eszip","npm","parsing","corruption","serialization"],"backgroundTag":"corrupted-eszip-archive","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}