{"record":{"id":"00fab1b9e1c3e1f3","repo":"denoland/deno","slug":"invalid-utf-8-data","errorCode":null,"errorMessage":"invalid utf-8 data","messagePattern":"invalid utf-8 data","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"libs/eszip/v2.rs","lineNumber":1882,"sourceCode":"    ))\n  }\n}\n\nstruct EszipNpmDependency(String, EszipNpmPackageIndex);\n\nimpl EszipNpmDependency {\n  pub fn parse(input: &[u8]) -> std::io::Result<(&[u8], Self)> {\n    let (input, name) = parse_string(input)?;\n    let (input, pkg_index) = EszipNpmPackageIndex::parse(input)?;\n    Ok((input, EszipNpmDependency(name, pkg_index)))\n  }\n}\n\nfn parse_string(input: &[u8]) -> std::io::Result<(&[u8], String)> {\n  let (input, size) = parse_u32(input)?;\n  let (input, name) = move_bytes(input, size as usize)?;\n  let text = String::from_utf8(name.to_vec()).map_err(|_| {\n    std::io::Error::new(std::io::ErrorKind::InvalidData, \"invalid utf-8 data\")\n  })?;\n  Ok((input, text))\n}\n\nfn parse_u32(input: &[u8]) -> std::io::Result<(&[u8], u32)> {\n  let (input, value_bytes) = move_bytes(input, 4)?;\n  let value = u32::from_be_bytes(value_bytes.try_into().unwrap());\n  Ok((input, value))\n}\n\nfn move_bytes(\n  bytes: &[u8],\n  len: usize,\n) -> Result<(&[u8], &[u8]), std::io::Error> {\n  if bytes.len() < len {\n    Err(std::io::Error::new(\n      std::io::ErrorKind::UnexpectedEof,\n      \"unexpected end of bytes\",","sourceCodeStart":1864,"sourceCodeEnd":1900,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/libs/eszip/v2.rs#L1864-L1900","documentation":"eszip v2 parser (used by deno compile artifacts and cached npm sections): npm dependency entries carry length-prefixed strings; parse_string converts the bytes with String::from_utf8. If the byte slice is not valid UTF-8, parsing aborts with ErrorKind::InvalidData and this message — the archive's npm section is corrupt.","triggerScenarios":"Loading an eszip (compiled binary or cached npm section) whose dependency-name bytes were corrupted: bit rot, truncated then re-padded download, partial write during creation, or mutation by transfer/patching tools.","commonSituations":"deno compile artifacts corrupted in artifact storage or CI caching; interrupted downloads resumed incorrectly; npm cache eszip files corrupted after disk-full events; files mangled by text-mode transfer (FTP/editor).","solutions":["Rebuild the artifact: re-run deno compile from a clean checkout and redistribute.","Delete the cached copy (DENO_DIR npm cache / the downloaded binary) and re-download from the original source.","Verify integrity before running: compare size and sha256 against the value recorded at build time.","Check for disk-full or interrupted-write conditions on the machine that produced the artifact."],"exampleFix":"# before\ndeno run --cached-only app.ts        # corrupt eszip in cache -> invalid utf-8 data\n\n# after\ndeno clean                            # or: rm -rf \"$DENO_DIR/npm\"\ndeno cache main.ts && deno run app.ts\n# for compiled binaries: re-run `deno compile` and replace the artifact","handlingStrategy":"fallback","validationCode":"import { createHash } from \"node:crypto\";\nimport { readFile } from \"node:fs/promises\";\nasync function verify(artifact, expectedSha) {\n  const actual = createHash(\"sha256\").update(await readFile(artifact)).digest(\"hex\");\n  if (actual !== expectedSha) throw new Error(`artifact corrupt (sha mismatch): ${artifact}`);\n}","typeGuard":null,"tryCatchPattern":"try { await run(); } catch (e) { if (/invalid utf-8 data/.test(String(e))) { await rebuildArtifact(); /* recompile/redownload then retry */ } else throw e; }","preventionTips":["Record size+sha256 of deno compile artifacts at build time and verify before every run.","Do not resume interrupted downloads of eszip-bearing files; restart them atomically (write to temp, rename).","Keep CI cache keys content-addressed so corrupt cache entries are never reused."],"tags":["eszip","corruption","utf-8","npm-cache","compile-artifact"],"backgroundTag":"corrupt-archive","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T04:17:50.494Z"}