{"record":{"id":"0ed8899dfbd374e4","repo":"nexu-io/open-design","slug":"invalid-zip-central-directory","errorCode":null,"errorMessage":"invalid zip central directory","messagePattern":"invalid zip central directory","errorType":"validation","errorClass":"Error","httpStatus":400,"severity":"error","filePath":"apps/daemon/src/design/claude-design-import.ts","lineNumber":189,"sourceCode":"    // trackpad. Ignore those here; explicit zoom is Cmd+wheel or the host\n    // toolbar.\n    let isGesturing = false;\n    const onGestureStart = (e) => { e.preventDefault(); e.stopPropagation(); isGesturing = true; };\n    const onGestureChange = (e) => {\n      e.preventDefault();\n      e.stopPropagation();\n    };\n    const onGestureEnd = (e) => { e.preventDefault(); e.stopPropagation(); isGesturing = false; };`);\n  return { result, wheelMatched, gestureMatched };\n}\n\nfunction readCentralDirectory(zip: Buffer): ZipEntry[] {\n  const eocdOffset = findEndOfCentralDirectory(zip);\n  const entryCount = zip.readUInt16LE(eocdOffset + 10);\n  const centralSize = zip.readUInt32LE(eocdOffset + 12);\n  const centralOffset = zip.readUInt32LE(eocdOffset + 16);\n  if (centralOffset + centralSize > zip.length) {\n    throw new Error('invalid zip central directory');\n  }\n\n  const entries: ZipEntry[] = [];\n  let offset = centralOffset;\n  for (let i = 0; i < entryCount; i += 1) {\n    if (zip.readUInt32LE(offset) !== CENTRAL_SIG) {\n      throw new Error('invalid zip central directory entry');\n    }\n    const flags = zip.readUInt16LE(offset + 8);\n    const method = zip.readUInt16LE(offset + 10);\n    const compressedSize = zip.readUInt32LE(offset + 20);\n    const uncompressedSize = zip.readUInt32LE(offset + 24);\n    const nameLen = zip.readUInt16LE(offset + 28);\n    const extraLen = zip.readUInt16LE(offset + 30);\n    const commentLen = zip.readUInt16LE(offset + 32);\n    const localOffset = zip.readUInt32LE(offset + 42);\n    const name = zip.slice(offset + 46, offset + 46 + nameLen).toString('utf8');\n    if ((flags & 1) !== 0) throw new Error('encrypted zip entries are not supported');","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/design/claude-design-import.ts#L171-L207","documentation":"Thrown by `readCentralDirectory` when the end-of-central-directory record's `centralOffset + centralSize` exceeds the actual archive buffer length. The central directory points past the end of the file, so the archive is truncated or corrupt and cannot be safely parsed.","triggerScenarios":"A zip whose EOCD record advertises a central directory offset/size that extends beyond the file bytes held in memory — e.g. a partially downloaded archive, a truncated file, or a corrupt/truncated central directory.","commonSituations":"The zip was truncated during download or transfer. Disk write was interrupted. A buggy producer wrote an inconsistent EOCD. An attacker crafted a misleading EOCD.","solutions":["Re-obtain the zip from the original source to rule out truncation during transfer.","Verify integrity with a standard unzip tool; if it fails to list contents, the archive is corrupt.","If you produce the archive, ensure the writer flushes the full file and writes a consistent EOCD."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const eocdOffset = findEndOfCentralDirectory(zip);\nconst centralSize = zip.readUInt32LE(eocdOffset + 12);\nconst centralOffset = zip.readUInt32LE(eocdOffset + 16);\nif (centralOffset + centralSize > zip.length) {\n  throw new Error('archive central directory extends past end of file; archive is truncated');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await importClaudeDesignZip(zipPath, projectDir);\n} catch (err) {\n  if (err instanceof Error && err.message === 'invalid zip central directory') {\n    // re-obtain the archive; it is truncated or corrupt\n  }\n  throw err;\n}","preventionTips":["Re-obtain archives from the original source to rule out truncation during transfer.","Verify archive integrity with a standard unzip tool before importing.","Ensure the zip writer flushes the full file and writes a consistent EOCD."],"tags":["zip","claude-design","validation","data-integrity","import"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}