paperclipai/paperclip · error · Error

Invalid zip archive: central directory size does not match i

Error message

Invalid zip archive: central directory size does not match its records.

What it means

Error "Invalid zip archive: central directory size does not match its records." thrown in paperclipai/paperclip.

Source

Thrown at packages/shared/src/portability-zip.ts:118

  let cursor = centralDirectoryStart;
  let recordCount = 0;
  while (cursor < directoryEnd) {
    if (cursor + 46 > directoryEnd || readUint32(bytes, cursor) !== CENTRAL_DIRECTORY_SIGNATURE) {
      throw new Error("Invalid zip archive: malformed central directory record.");
    }
    const fileNameLength = readUint16(bytes, cursor + 28);
    const extraFieldLength = readUint16(bytes, cursor + 30);
    const commentLength = readUint16(bytes, cursor + 32);
    const localHeaderOffset = readUint32(bytes, cursor + 42);
    if (localHeaderOffset + 4 > bytes.length || readUint32(bytes, localHeaderOffset) !== LOCAL_FILE_SIGNATURE) {
      throw new Error("Invalid zip archive: central directory references a missing local entry.");
    }
    cursor += 46 + fileNameLength + extraFieldLength + commentLength;
    recordCount += 1;
  }

  if (cursor !== directoryEnd) {
    throw new Error("Invalid zip archive: central directory size does not match its records.");
  }
  if (recordCount !== declaredEntryCount || recordCount !== localHeaderCount) {
    throw new Error(
      `Invalid zip archive: central directory declares ${declaredEntryCount} entries but ${localHeaderCount} local entries were read (truncated or corrupt).`,
    );
  }
}

function sharedArchiveRoot(paths: string[]) {
  if (paths.length === 0) return null;
  const firstSegments = paths
    .map((entry) => normalizeArchivePath(entry).split("/").filter(Boolean))
    .filter((parts) => parts.length > 0);
  if (firstSegments.length === 0) return null;
  const candidate = firstSegments[0]![0]!;
  return firstSegments.every((parts) => parts.length > 1 && parts[0] === candidate)
    ? candidate
    : null;

View on GitHub (pinned to 120ae5428f)

Solutions

  1. Re-create the archive; central directory size is inconsistent with its records.

When it happens

Trigger: Thrown at packages/shared/src/portability-zip.ts:118 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@120ae5428f (2026-08-18). Data as JSON: /api/errors/ea2b0487a9f1012d. Report an issue: GitHub.