{"record":{"id":"deeecbf4e7e08e89","repo":"can1357/oh-my-pi","slug":"unsupported-rar4-compression-method-0x-methodbyte","errorCode":null,"errorMessage":"Unsupported RAR4 compression method 0x${methodByte.toString(16)}","messagePattern":"Unsupported RAR4 compression method 0x(.+?)","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/rar.ts","lineNumber":510,"sourceCode":"\t\t\tconst methodByte = bytes[cursor++]!;\n\t\t\tconst nameSize = readUInt16LE(bytes, cursor);\n\t\t\tcursor += 2;\n\t\t\tconst attributes = readUInt32LE(bytes, cursor);\n\t\t\tcursor += 4;\n\t\t\tlet packedSize = dataSize;\n\t\t\tlet unpackedSize = unpackedLow;\n\t\t\tif ((flags & 0x100) !== 0) {\n\t\t\t\tneed(cursor, 8, headerEnd, \"RAR4 high sizes\");\n\t\t\t\tpackedSize += readUInt32LE(bytes, cursor) * 0x100000000;\n\t\t\t\tcursor += 4;\n\t\t\t\tunpackedSize += readUInt32LE(bytes, cursor) * 0x100000000;\n\t\t\t\tcursor += 4;\n\t\t\t\tdataEnd = checkedEnd(dataStart, packedSize, bytes.byteLength, \"RAR4 file data\");\n\t\t\t}\n\t\t\tif ((flags & 3) !== 0) throw new ArchiveError(\"Unsupported multi-volume RAR4 member\");\n\t\t\tif ((flags & 4) !== 0) throw new ArchiveError(\"Encrypted RAR4 file data is not supported\");\n\t\t\tif (methodByte < 0x30 || methodByte > 0x35)\n\t\t\t\tthrow new ArchiveError(`Unsupported RAR4 compression method 0x${methodByte.toString(16)}`);\n\t\t\tassertArchivePathBytes(nameSize, \"member path\", options.limits.maxPathBytes);\n\t\t\tneed(cursor, nameSize, headerEnd, \"RAR4 file name\");\n\t\t\tconst nameBytes = bytes.subarray(cursor, cursor + nameSize);\n\t\t\tconst rawPath = (flags & 0x200) !== 0 ? decodeRar4UnicodeName(nameBytes) : LATIN1.decode(nameBytes);\n\t\t\tcursor += nameSize;\n\t\t\tif ((flags & 0x400) !== 0) {\n\t\t\t\tneed(cursor, 8, headerEnd, \"RAR4 salt\");\n\t\t\t\tcursor += 8;\n\t\t\t}\n\t\t\tlet mtimeMs = dosTimeMs(dosTime);\n\t\t\tif ((flags & 0x1000) !== 0) {\n\t\t\t\tneed(cursor, 2, headerEnd, \"RAR4 extended time flags\");\n\t\t\t\tconst timeFlags = readUInt16LE(bytes, cursor);\n\t\t\t\tcursor += 2;\n\t\t\t\tfor (let timeIndex = 0; timeIndex < 4; timeIndex++) {\n\t\t\t\t\tconst mode = (timeFlags >>> ((3 - timeIndex) * 4)) & 15;\n\t\t\t\t\tif ((mode & 8) === 0) continue;\n\t\t\t\t\tlet timeValue = dosTime;","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/rar.ts#L492-L528","documentation":"RAR4 stores a compression method byte in each file header; 0x30–0x35 are the valid codes (store plus RAR 1.5–5 compression levels). parseRar4 rejects any method byte outside that range because the unpacker cannot decode it. Values outside the range indicate corruption, a format the parser misidentified, or nonstandard tooling.","triggerScenarios":"Calling records() on a corrupted RAR4 file (method byte overwritten), on data misdetected as RAR4, or on archives produced by nonstandard/modified RAR tools.","commonSituations":"Truncated or bit-rotted downloads; files with wrong extension fed to the reader; experimental RAR forks.","solutions":["Verify the archive's integrity (re-download / check checksum) — a bad method byte usually means corruption.","Confirm the file actually is RAR4 (magic Rar!\\x1a\\x07\\x00) and not another format misdetected.","Re-create the archive with standard WinRAR/rar settings.","Catch ArchiveError and fall back to an external extractor that may handle the variant."],"exampleFix":"// before: parsing a corrupted file\nawait records(Bun.file(\"maybe.rar\"))\n// after: validate first\n$`unrar t maybe.rar` // integrity test before use","handlingStrategy":"validation","validationCode":"// verify integrity with an external tool before parsing\nconst proc = Bun.$`unrar t ${archivePath}`.quiet().nothrow();\nif ((await proc).exitCode !== 0) throw new Error(\"archive failed integrity test\");","typeGuard":null,"tryCatchPattern":"try {\n  const recs = await records(file);\n} catch (err) {\n  if (err instanceof ArchiveError && /Unsupported RAR4 compression method/.test(err.message)) {\n    // treat archive as corrupt; request re-upload\n  } else throw err;\n}","preventionTips":["Checksum-verify downloads before parsing.","Run `unrar t` as an intake gate.","Confirm format detection (RAR4 magic) before parse.","Reject archives from nonstandard RAR tools."],"tags":["archive","rar4","corruption","compression-method"],"backgroundTag":"corrupt-archive-header","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}