{"record":{"id":"06e06d29e06d8e07","repo":"can1357/oh-my-pi","slug":"unsupported-cab-compression-method-description","errorCode":null,"errorMessage":"Unsupported CAB compression method: ${description.method}","messagePattern":"Unsupported CAB compression method: (.+?)","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/cab.ts","lineNumber":133,"sourceCode":"\tconstructor(source: ByteSource, description: CabFolderDescription, dataReserveSize: number, limits: ArchiveLimits) {\n\t\tthis.#source = source;\n\t\tthis.#description = description;\n\t\tthis.#dataReserveSize = dataReserveSize;\n\t\tthis.#limits = limits;\n\t}\n\n\treadAll(): Promise<Uint8Array> {\n\t\tthis.#decoded ??= this.#decode();\n\t\treturn this.#decoded;\n\t}\n\n\tasync #decode(): Promise<Uint8Array> {\n\t\tconst description = this.#description;\n\t\tif (description.method === 2) {\n\t\t\tthrow new ArchiveError(`Unsupported CAB compression method: Quantum (level ${description.parameter})`);\n\t\t}\n\t\tif (description.method > 3) {\n\t\t\tthrow new ArchiveError(`Unsupported CAB compression method: ${description.method}`);\n\t\t}\n\t\tif (description.method === 3 && (description.parameter < 15 || description.parameter > 21)) {\n\t\t\tthrow new ArchiveError(`Unsupported CAB LZX window size: ${description.parameter} bits (expected 15-21)`);\n\t\t}\n\n\t\tconst compressedSize = description.dataEnd - description.dataStart;\n\t\tassertInMemorySize(compressedSize, this.#limits);\n\t\tconst bytes = await readExact(this.#source, description.dataStart, description.dataEnd);\n\t\tlet position = 0;\n\t\tlet outputSize = 0;\n\t\tfor (let block = 0; block < description.blockCount; block++) {\n\t\t\tif (position + DATA_BLOCK_SIZE + this.#dataReserveSize > bytes.byteLength) {\n\t\t\t\tthrow new ArchiveError(\"Invalid CAB archive: truncated CFDATA header\");\n\t\t\t}\n\t\t\tconst compressed = readUInt16LE(bytes, position + 4);\n\t\t\tconst uncompressed = readUInt16LE(bytes, position + 6);\n\t\t\tif (uncompressed === 0) throw new ArchiveError(\"Unsupported multi-volume CAB archive: split CFDATA block\");\n\t\t\tif (uncompressed > MAX_DATA_OUTPUT) {","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/cab.ts#L115-L151","documentation":"Any CFFOLDER compression method value greater than 3 is unknown to this library (known: 0=none, 1=deflate, 2=quantum, 3=LZX), so #decode refuses it rather than guessing. This usually means the archive is corrupt or uses a proprietary/undocumented method code. The raw method number is included in the message for diagnosis.","triggerScenarios":"readAll() on a CAB whose folder typeCompress field contains a value > 3 — from corruption, a maliciously crafted file, or a nonstandard producer writing custom method codes.","commonSituations":"Hand-crafted or fuzzed CAB inputs; corrupted headers where adjacent bytes bled into typeCompress; proprietary archivers that abused reserved method fields; wrong endianness assumptions in files produced by buggy tools.","solutions":["Log the reported method number and check it against the CAB spec; if it is far beyond 3, suspect corruption — re-download/re-copy the archive.","Validate the archive with `cabextract -t file.cab` to distinguish real unsupported methods from header corruption.","Re-create the CAB with a standard tool using Deflate (method 1) or LZX (method 3).","If the input is user-supplied, add an upfront signature/structure sanity check and reject such files with a clear message before invoking readAll().","If the method is genuinely needed, extend the decoder with a new branch (as done for LZX) rather than letting it fall into this error."],"exampleFix":"// before: trusting arbitrary uploaded .cab files\nawait readCabArchive(userUpload); // Unsupported CAB compression method: 17\n// after: pre-validate structure with an independent tool or reject early\nif (!looksLikeValidCab(await Bun.file(uploadPath).arrayBuffer()))\n  throw new Error('Not a structurally valid CAB file');\nawait readCabArchive(userUpload);","handlingStrategy":"validation","validationCode":"const method = readFolderCompressionMethod(cabBytes);\nif (method === undefined || method > 3)\n  throw new Error(`CAB folder has unknown compression method ${method} — file is corrupt or nonstandard`);","typeGuard":"function isKnownCabMethod(m: number | undefined): m is 0 | 1 | 2 | 3 {\n  return m !== undefined && m >= 0 && m <= 3;\n}","tryCatchPattern":"try {\n  return await readCabArchive(bytes);\n} catch (err) {\n  if (err instanceof ArchiveError && /compression method: \\d+$/.test(err.message)) {\n    throw new Error('Unknown CAB compression method — verify the archive is not corrupted');\n  }\n  throw err;\n}","preventionTips":["Validate CAB structure at ingestion boundaries for user-supplied files.","Re-checksum transferred CABs; method bytes are small and easily corrupted.","Only produce CABs with mainstream tooling (makecab, lcab).","Treat unknown method values as corruption, not as a feature gap."],"tags":["compression","unsupported","cab","validation"],"backgroundTag":"unsupported-compression-method","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}