{"record":{"id":"6ed8bff3959a5e54","repo":"can1357/oh-my-pi","slug":"unsupported-rar4-compression-algorithm-version-v","errorCode":null,"errorMessage":"Unsupported RAR4 compression algorithm version ${version}","messagePattern":"Unsupported RAR4 compression algorithm version (.+?)","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/rar/rar4-decoder.ts","lineNumber":156,"sourceCode":"\t\tthis.#oldDistances = [0, 0, 0, 0];\n\t\tthis.#lastDistance = 0;\n\t\tthis.#lastLength = 0;\n\t\tthis.#previousLowDistance = 0;\n\t\tthis.#lowDistanceRepeats = 0;\n\t\tthis.#carriedLengths.fill(0);\n\t\tthis.#filterTypes = [];\n\t\tthis.#filterLengths = [];\n\t\tthis.#lastFilter = 0;\n\t}\n\n\tdecode(\n\t\tpacked: Uint8Array,\n\t\tunpackedSize: number,\n\t\tdictionarySize: number,\n\t\tsolid: boolean,\n\t\tversion: number,\n\t): Uint8Array {\n\t\tif (version < 29) throw new ArchiveError(`Unsupported RAR4 compression algorithm version ${version}`);\n\t\tif (!solid) this.reset();\n\t\tconst prior =\n\t\t\tthis.#history.byteLength > dictionarySize\n\t\t\t\t? this.#history.subarray(this.#history.byteLength - dictionarySize)\n\t\t\t\t: this.#history;\n\t\tconst output = new Uint8Array(prior.byteLength + unpackedSize + 260);\n\t\toutput.set(prior);\n\t\tconst outputStart = prior.byteLength;\n\t\tconst outputEnd = outputStart + unpackedSize;\n\t\tlet outputPosition = outputStart;\n\t\tconst bits = new Bits(packed);\n\t\tconst main = new Huffman(MAIN_SIZE);\n\t\tconst distanceDecoder = new Huffman(DIST_SIZE);\n\t\tconst lowDistanceDecoder = new Huffman(LOW_DIST_SIZE);\n\t\tconst lengthDecoder = new Huffman(LEN_SIZE);\n\t\tconst filters: PendingFilter[] = [];\n\n\t\tconst readTables = (): void => {","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/rar/rar4-decoder.ts#L138-L174","documentation":"The RAR4 decoder's decode() only implements compression algorithm versions 29 and above (the standard RAR 2.9/3.x LZSS+Huffman scheme). A file header announcing an older method (version < 29, i.e. pre-2.9 RAR) is rejected before decoding begins. The library does not ship the legacy RAR 1.5–2.x decompressors.","triggerScenarios":"Decoding a RAR4 member whose compression-info version field is below 29 — typically archives created by RAR 1.5 through 2.x — passed through the archive reader's RAR4 decode path.","commonSituations":"Extracting very old RAR archives from the late 1990s/early 2000s; mislabeled or corrupted version fields in the file header; legacy data dumps re-shared today.","solutions":["Repack/re-compress the archive with a modern RAR (or convert to zip/7z/tar) using RAR 3+ or a third-party tool.","Extract the archive with a tool that supports legacy RAR (e.g. unrar with legacy support, 7-Zip) and feed the extracted files to this library instead.","Check the archive header version field to confirm; a wildly wrong value may indicate corruption rather than age.","If the version field is garbage (not a plausible old version), treat the archive as corrupt."],"exampleFix":"// before (shell)\nunrar-less extraction attempt with the library on a RAR 2.0 file\n// after (shell)\n7z x old-archive.rar -oextracted/  # then process extracted/ contents","handlingStrategy":"validation","validationCode":"// RAR4 file header compression version lives in the file header;\n// probe with an external pre-check or reject archives known to be RAR < 2.9.\nconst isModern = await isRar29Plus(p); // e.g. via `unrar t -p-` or header parse\nif (!isModern) throw new Error(`${p} uses legacy RAR compression (< v29); convert it first`);","typeGuard":null,"tryCatchPattern":"try {\n  await extractArchive(p, dest);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.includes(\"algorithm version\")) {\n    // fall back to an external tool (unrar/7z) or ask the user to repack\n  }\n  throw err;\n}","preventionTips":["Detect legacy RAR archives at ingest and convert them (7z a modern.zip) before processing.","Prefer zip/7z/tar for archival pipelines; avoid RAR 1.x/2.x sources.","Validate archives with `unrar t` before automated extraction.","Document a minimum RAR version (2.9+) wherever archives are accepted from users."],"tags":["archive","rar","rar4","unsupported-version","decompression"],"backgroundTag":"unsupported-compression-version","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}