paperclipai/paperclip · error · Error
Invalid zip archive: central directory location is inconsist
Error message
Invalid zip archive: central directory location is inconsistent (truncated or forged).
What it means
Error "Invalid zip archive: central directory location is inconsistent (truncated or forged)." thrown in paperclipai/paperclip.
Source
Thrown at packages/shared/src/portability-zip.ts:94
// Fully validate the central directory the EOCD advertises against the local
// entries actually read from the archive body. Trusting only the EOCD's entry
// count is not enough: a truncated archive with a forged 22-byte EOCD whose
// count matches the surviving local entries would otherwise be accepted, and the
// importer would silently process a partial company package (dropping agents,
// issues, and so on). This walks the real central directory and requires that:
// • it is fully present and sits immediately before the EOCD (no gap, no
// pointer past the buffer — a truncated tail fails here);
// • every record carries the central-directory signature and its lengths sum
// to exactly the declared directory size; and
// • every record references a real local file header, and the record count
// equals both the EOCD's declared count and the local entries parsed.
function validateCentralDirectory(bytes: Uint8Array, eocdOffset: number, localHeaderCount: number) {
const declaredEntryCount = readUint16(bytes, eocdOffset + 10);
const centralDirectorySize = readUint32(bytes, eocdOffset + 12);
const centralDirectoryStart = readUint32(bytes, eocdOffset + 16);
if (centralDirectoryStart > eocdOffset || centralDirectoryStart + centralDirectorySize !== eocdOffset) {
throw new Error(
"Invalid zip archive: central directory location is inconsistent (truncated or forged).",
);
}
const directoryEnd = centralDirectoryStart + centralDirectorySize;
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.");
}View on GitHub (pinned to 120ae5428f)
Solutions
- Re-download or rebuild the zip archive; the file is truncated or forged.
When it happens
Trigger: Thrown at packages/shared/src/portability-zip.ts:94 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/805e8ce867e48635.
Report an issue: GitHub.