{"record":{"id":"6fb4f023c8134fa9","repo":"different-ai/openwork","slug":"failed-to-find-zip-central-directory","errorCode":null,"errorMessage":"Failed to find ZIP central directory.","messagePattern":"Failed to find ZIP central directory\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/desktop/electron/workspace-archive.mjs","lineNumber":184,"sourceCode":"    const local = localFileHeader(nameBuffer, data, checksum);\n    chunks.push(local, nameBuffer, data);\n    central.push(centralDirectoryHeader(nameBuffer, data, checksum, offset), nameBuffer);\n    offset += local.length + nameBuffer.length + data.length;\n  }\n\n  const centralOffset = offset;\n  const centralSize = central.reduce((sum, chunk) => sum + chunk.length, 0);\n  chunks.push(...central, endOfCentralDirectory(files.length, centralSize, centralOffset));\n  await mkdir(path.dirname(outputPath), { recursive: true });\n  await writeFile(outputPath, Buffer.concat(chunks));\n}\n\nfunction findEndOfCentralDirectory(buffer) {\n  const start = Math.max(0, buffer.length - 0xffff - 22);\n  for (let offset = buffer.length - 22; offset >= start; offset -= 1) {\n    if (buffer.readUInt32LE(offset) === ZIP_END_OF_CENTRAL_DIRECTORY) return offset;\n  }\n  throw new Error(\"Failed to find ZIP central directory.\");\n}\n\nfunction listZipEntries(buffer) {\n  if (buffer.byteLength > MAX_ARCHIVE_BYTES) throw new Error(\"Workspace archive is too large.\");\n  const eocd = findEndOfCentralDirectory(buffer);\n  const count = buffer.readUInt16LE(eocd + 10);\n  if (count > MAX_ARCHIVE_ENTRIES) throw new Error(\"Workspace archive contains too many entries.\");\n  const centralOffset = buffer.readUInt32LE(eocd + 16);\n  const entries = [];\n  let totalUncompressed = 0;\n  let cursor = centralOffset;\n  for (let i = 0; i < count; i += 1) {\n    if (buffer.readUInt32LE(cursor) !== ZIP_CENTRAL_DIRECTORY_HEADER) {\n      throw new Error(\"Invalid ZIP central directory entry.\");\n    }\n    const method = buffer.readUInt16LE(cursor + 10);\n    const compressedSize = buffer.readUInt32LE(cursor + 20);\n    const uncompressedSize = buffer.readUInt32LE(cursor + 24);","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/desktop/electron/workspace-archive.mjs#L166-L202","documentation":"Error \"Failed to find ZIP central directory.\" thrown in different-ai/openwork.","triggerScenarios":"Thrown at apps/desktop/electron/workspace-archive.mjs:184 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}