{"record":{"id":"b419132cf2f32bc5","repo":"paperclipai/paperclip","slug":"invalid-zip-archive-truncated-local-file-header-b41913","errorCode":null,"errorMessage":"Invalid zip archive: truncated local file header.","messagePattern":"Invalid zip archive: truncated local file header\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ui/src/lib/zip.ts","lineNumber":197,"sourceCode":"}\n\nexport async function readZipArchive(source: ArrayBuffer | Uint8Array): Promise<{\n  rootPath: string | null;\n  files: Record<string, CompanyPortabilityFileEntry>;\n}> {\n  const bytes = source instanceof Uint8Array ? source : new Uint8Array(source);\n  const entries: Array<{ path: string; body: CompanyPortabilityFileEntry }> = [];\n  let offset = 0;\n\n  while (offset + 4 <= bytes.length) {\n    const signature = readUint32(bytes, offset);\n    if (signature === 0x02014b50 || signature === 0x06054b50) break;\n    if (signature !== 0x04034b50) {\n      throw new Error(\"Invalid zip archive: unsupported local file header.\");\n    }\n\n    if (offset + 30 > bytes.length) {\n      throw new Error(\"Invalid zip archive: truncated local file header.\");\n    }\n\n    const generalPurposeFlag = readUint16(bytes, offset + 6);\n    const compressionMethod = readUint16(bytes, offset + 8);\n    const compressedSize = readUint32(bytes, offset + 18);\n    const fileNameLength = readUint16(bytes, offset + 26);\n    const extraFieldLength = readUint16(bytes, offset + 28);\n\n    if ((generalPurposeFlag & 0x0008) !== 0) {\n      throw new Error(\"Unsupported zip archive: data descriptors are not supported.\");\n    }\n\n    const nameOffset = offset + 30;\n    const bodyOffset = nameOffset + fileNameLength + extraFieldLength;\n    const bodyEnd = bodyOffset + compressedSize;\n    if (bodyEnd > bytes.length) {\n      throw new Error(\"Invalid zip archive: truncated file contents.\");\n    }","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/ui/src/lib/zip.ts#L179-L215","documentation":"Browser zip reader structural validation: a local file header started near the end of the buffer so the fixed 30-byte header cannot fit within the remaining bytes. The archive is truncated (interrupted download or bad export); re-download/re-export the archive.","triggerScenarios":"Thrown at ui/src/lib/zip.ts:197 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-download or re-export the zip; the archive is truncated. Then retry the import."],"exampleFix":null,"handlingStrategy":"validation","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-14T00:17:10.932Z"}