paperclipai/paperclip · error · Error
Invalid zip archive: malformed central directory record.
Error message
Invalid zip archive: malformed central directory record.
What it means
Error "Invalid zip archive: malformed central directory record." thrown in paperclipai/paperclip.
Source
Thrown at packages/shared/src/portability-zip.ts:104
// 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.");
}
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).`,View on GitHub (pinned to 120ae5428f)
Solutions
- Re-create the archive with a standard zip tool; the central directory is malformed.
When it happens
Trigger: Thrown at packages/shared/src/portability-zip.ts:104 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of paperclipai/paperclip@120ae5428f (2026-08-18).
Data as JSON: /api/errors/b3f353f8a9957861.
Report an issue: GitHub.