{"record":{"id":"ea2b0487a9f1012d","repo":"paperclipai/paperclip","slug":"invalid-zip-archive-central-directory-size-does-n","errorCode":null,"errorMessage":"Invalid zip archive: central directory size does not match its records.","messagePattern":"Invalid zip archive: central directory size does not match its records\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/src/portability-zip.ts","lineNumber":118,"sourceCode":"  let cursor = centralDirectoryStart;\n  let recordCount = 0;\n  while (cursor < directoryEnd) {\n    if (cursor + 46 > directoryEnd || readUint32(bytes, cursor) !== CENTRAL_DIRECTORY_SIGNATURE) {\n      throw new Error(\"Invalid zip archive: malformed central directory record.\");\n    }\n    const fileNameLength = readUint16(bytes, cursor + 28);\n    const extraFieldLength = readUint16(bytes, cursor + 30);\n    const commentLength = readUint16(bytes, cursor + 32);\n    const localHeaderOffset = readUint32(bytes, cursor + 42);\n    if (localHeaderOffset + 4 > bytes.length || readUint32(bytes, localHeaderOffset) !== LOCAL_FILE_SIGNATURE) {\n      throw new Error(\"Invalid zip archive: central directory references a missing local entry.\");\n    }\n    cursor += 46 + fileNameLength + extraFieldLength + commentLength;\n    recordCount += 1;\n  }\n\n  if (cursor !== directoryEnd) {\n    throw new Error(\"Invalid zip archive: central directory size does not match its records.\");\n  }\n  if (recordCount !== declaredEntryCount || recordCount !== localHeaderCount) {\n    throw new Error(\n      `Invalid zip archive: central directory declares ${declaredEntryCount} entries but ${localHeaderCount} local entries were read (truncated or corrupt).`,\n    );\n  }\n}\n\nfunction sharedArchiveRoot(paths: string[]) {\n  if (paths.length === 0) return null;\n  const firstSegments = paths\n    .map((entry) => normalizeArchivePath(entry).split(\"/\").filter(Boolean))\n    .filter((parts) => parts.length > 0);\n  if (firstSegments.length === 0) return null;\n  const candidate = firstSegments[0]![0]!;\n  return firstSegments.every((parts) => parts.length > 1 && parts[0] === candidate)\n    ? candidate\n    : null;","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/packages/shared/src/portability-zip.ts#L100-L136","documentation":"Error \"Invalid zip archive: central directory size does not match its records.\" thrown in paperclipai/paperclip.","triggerScenarios":"Thrown at packages/shared/src/portability-zip.ts:118 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-create the archive; central directory size is inconsistent with its records."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}