{"record":{"id":"16b0d1331f40ece5","repo":"different-ai/openwork","slug":"zip-entry-name-uses-unsupported-compression-met","errorCode":null,"errorMessage":"ZIP entry ${name} uses unsupported compression method ${method}.","messagePattern":"ZIP entry (.+?) uses unsupported compression method (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/server/src/opencode-plugins/openwork-office-attachments.ts","lineNumber":297,"sourceCode":"\n  const entries: ZipEntry[] = [];\n  let cursor = centralOffset;\n  let totalUncompressed = 0;\n  for (let index = 0; index < count; index += 1) {\n    if (cursor + 46 > centralEnd || buffer.readUInt32LE(cursor) !== ZIP_CENTRAL_DIRECTORY_HEADER) throw new Error(\"Invalid ZIP central directory entry.\");\n    const flags = buffer.readUInt16LE(cursor + 8);\n    const method = buffer.readUInt16LE(cursor + 10);\n    const compressedSize = buffer.readUInt32LE(cursor + 20);\n    const uncompressedSize = buffer.readUInt32LE(cursor + 24);\n    const nameLength = buffer.readUInt16LE(cursor + 28);\n    const extraLength = buffer.readUInt16LE(cursor + 30);\n    const commentLength = buffer.readUInt16LE(cursor + 32);\n    const localOffset = buffer.readUInt32LE(cursor + 42);\n    if (compressedSize === 0xffffffff || uncompressedSize === 0xffffffff || localOffset === 0xffffffff) throw new Error(\"ZIP64 archives are not supported.\");\n    if (cursor + 46 + nameLength + extraLength + commentLength > centralEnd) throw new Error(\"ZIP central directory entry is out of bounds.\");\n    const name = buffer.toString(\"utf8\", cursor + 46, cursor + 46 + nameLength);\n    rejectUnsafeZipFlags(flags, name);\n    if (method !== ZIP_STORED && method !== ZIP_DEFLATE) throw new Error(`ZIP entry ${name} uses unsupported compression method ${method}.`);\n    if (uncompressedSize > MAX_ENTRY_UNCOMPRESSED_BYTES) throw new Error(`ZIP entry ${name} exceeds per-entry uncompressed limit.`);\n    if (uncompressedSize > 0 && compressedSize === 0) throw new Error(`ZIP entry ${name} has an invalid compression ratio.`);\n    if (compressedSize > 0 && uncompressedSize / compressedSize > MAX_ZIP_COMPRESSION_RATIO) throw new Error(`ZIP entry ${name} exceeds compression ratio limit.`);\n    totalUncompressed += uncompressedSize;\n    if (totalUncompressed > MAX_TOTAL_UNCOMPRESSED_BYTES) throw new Error(\"ZIP archive exceeds total uncompressed limit.\");\n    entries.push({ name, flags, method, compressedSize, uncompressedSize, localOffset });\n    cursor += 46 + nameLength + extraLength + commentLength;\n  }\n  if (cursor !== centralEnd) throw new Error(\"ZIP central directory size does not match its entries.\");\n  return entries;\n}\n\nfunction readZipEntryData(buffer: Buffer, entry: ZipEntry): Buffer {\n  const cursor = entry.localOffset;\n  if (cursor + 30 > buffer.byteLength || buffer.readUInt32LE(cursor) !== ZIP_LOCAL_FILE_HEADER) throw new Error(`Invalid local ZIP header for ${entry.name}.`);\n  const localFlags = buffer.readUInt16LE(cursor + 6);\n  const localMethod = buffer.readUInt16LE(cursor + 8);\n  const localCompressedSize = buffer.readUInt32LE(cursor + 18);","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/server/src/opencode-plugins/openwork-office-attachments.ts#L279-L315","documentation":"After reading each central-directory entry's compression method, listZipEntries accepts only ZIP_STORED (0) and ZIP_DEFLATE (8). Any other method (bzip2, LZMA, AES-encrypted pseudo-methods, etc.) is rejected by name to keep the decompressor surface minimal and safe.","triggerScenarios":"Extracting an office attachment where an entry's central-directory method byte is not 0 or 8 — e.g. ZIP created with bzip2/LZMA compression, an AES-encrypted archive (method 99), or a corrupted method field.","commonSituations":"Files compressed with 'zip -Z bzip2' or 7-Zip's LZMA; password-protected/AES ZIPs from tools like 7-Zip; corrupted header bytes after truncation.","solutions":["Re-create the archive with standard deflate compression: 'zip -Z deflate' or default 7-Zip/OS settings without encryption.","Remove password/AES encryption from the archive before uploading.","Re-export the office document from its native app (which writes deflate/store entries).","Verify the method field is intact if the file is merely corrupted — get a fresh copy."],"exampleFix":"// before\n7z a -tlzma archive.zip doc.docx  // LZMA method -> rejected\n// after\n7z a -tzip archive.zip doc.docx   // deflate -> accepted","handlingStrategy":"try-catch","validationCode":"import { unzip } from 'fflate'\n// pre-flight with a standard parser to surface method errors early:\nconst files = unzipSync(buf) // throws on unsupported methods with a familiar message","typeGuard":"function isSupportedZipMethod(method: number): method is 0 | 8 {\n  return method === 0 || method === 8\n}","tryCatchPattern":"try {\n  const entries = await extractOfficeAttachments(file)\n} catch (e) {\n  if (e instanceof Error && /unsupported compression method/.test(e.message)) {\n    const m = /method (\\d+)/.exec(e.message)?.[1]\n    alertUser(`archive uses unsupported compression (method ${m}); re-zip with deflate, no encryption`)\n  } else throw e\n}","preventionTips":["Create ZIPs with default deflate (no bzip2/LZMA) for attachments","Never upload password-protected/AES ZIPs to automated pipelines","Prefer exporting office files natively rather than re-zipping","Probe with a standard unzip library before running restricted parsers"],"tags":["zip","compression","file-parsing","security"],"backgroundTag":"unsupported-zip-compression","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}