denoland/deno · error · ParseError

missing index '{}'

Error message

missing index '{}'

What it means

While parsing the npm-packages section of an eszip v2 archive, a package dependency referenced an EszipNpmPackageIndex that does not exist in the archive's package index table. The archive is internally inconsistent; the error is wrapped in ParseError::InvalidV2NpmPackage together with the package name.

Source

Thrown at libs/eszip/v2.rs:1785

  let mut pkg_index_to_pkg_id = HashMap::with_capacity(packages.len());
  for (i, pkg) in packages.iter().enumerate() {
    let id = NpmPackageId::from_serialized(&pkg.name).map_err(|err| {
      ParseError::InvalidV2NpmPackage(pkg.name.clone(), err.into())
    })?;
    pkg_index_to_pkg_id.insert(EszipNpmPackageIndex(i as u32), id);
  }
  let mut final_packages = Vec::with_capacity(packages.len());
  for (i, pkg) in packages.into_iter().enumerate() {
    let eszip_id = EszipNpmPackageIndex(i as u32);
    let id = pkg_index_to_pkg_id.get(&eszip_id).unwrap();
    let mut dependencies = HashMap::with_capacity(pkg.dependencies.len());
    for (key, pkg_index) in pkg.dependencies {
      let id = match pkg_index_to_pkg_id.get(&pkg_index) {
        Some(id) => id,
        None => {
          return Err(ParseError::InvalidV2NpmPackage(
            pkg.name,
            anyhow::anyhow!("missing index '{}'", pkg_index.0),
          ));
        }
      };
      dependencies.insert(StackString::from_string(key), id.clone());
    }
    final_packages.push(SerializedNpmResolutionSnapshotPackage {
      id: id.clone(),
      system: Default::default(),
      dist: Default::default(),
      dependencies,
      optional_dependencies: Default::default(),
      extra: Default::default(),
      is_deprecated: false,
      has_bin: false,
      has_scripts: false,
      optional_peer_dependencies: Default::default(),
    });
  }

View on GitHub (pinned to 89f33cbef2)

Solutions

  1. Regenerate or re-download the eszip/compiled binary from its original source
  2. Verify integrity (checksum/size) at transfer boundaries such as artifact stores and caches
  3. Pin producer and consumer to the same Deno/eszip version when generating archives programmatically
Defensive patterns

Strategy: try-catch

Validate before calling

# verify the artifact before parsing it
sha256sum -c compiled.bin.sha256

Try / catch

match EszipV2::parse(reader) {
  Err(ParseError::InvalidV2NpmPackage(name, e)) => {
    // archive is internally inconsistent: re-download or rebuild it
    rebuild_artifact(&name)
  }
  result => result?,
}

Prevention

When it happens

Trigger: Running EszipV2::parse on a truncated, corrupted, or hand-modified archive; archives written by an eszip version whose index layout differs from the reader's.

Common situations: Partially downloaded or copied compiled binaries; corrupted CI cache layers; compile artifacts produced and consumed by different Deno/eszip versions after a format change.

Related errors


AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16). Data as JSON: /api/errors/fa73f6e7f38daca6. Report an issue: GitHub.