can1357/oh-my-pi · error · ArchiveError

Unsupported RAR4 compression method 0x${methodByte.toString(

Error message

Unsupported RAR4 compression method 0x${methodByte.toString(16)}

What it means

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.

Source

Thrown at packages/utils/src/ar/rar.ts:510

			const methodByte = bytes[cursor++]!;
			const nameSize = readUInt16LE(bytes, cursor);
			cursor += 2;
			const attributes = readUInt32LE(bytes, cursor);
			cursor += 4;
			let packedSize = dataSize;
			let unpackedSize = unpackedLow;
			if ((flags & 0x100) !== 0) {
				need(cursor, 8, headerEnd, "RAR4 high sizes");
				packedSize += readUInt32LE(bytes, cursor) * 0x100000000;
				cursor += 4;
				unpackedSize += readUInt32LE(bytes, cursor) * 0x100000000;
				cursor += 4;
				dataEnd = checkedEnd(dataStart, packedSize, bytes.byteLength, "RAR4 file data");
			}
			if ((flags & 3) !== 0) throw new ArchiveError("Unsupported multi-volume RAR4 member");
			if ((flags & 4) !== 0) throw new ArchiveError("Encrypted RAR4 file data is not supported");
			if (methodByte < 0x30 || methodByte > 0x35)
				throw new ArchiveError(`Unsupported RAR4 compression method 0x${methodByte.toString(16)}`);
			assertArchivePathBytes(nameSize, "member path", options.limits.maxPathBytes);
			need(cursor, nameSize, headerEnd, "RAR4 file name");
			const nameBytes = bytes.subarray(cursor, cursor + nameSize);
			const rawPath = (flags & 0x200) !== 0 ? decodeRar4UnicodeName(nameBytes) : LATIN1.decode(nameBytes);
			cursor += nameSize;
			if ((flags & 0x400) !== 0) {
				need(cursor, 8, headerEnd, "RAR4 salt");
				cursor += 8;
			}
			let mtimeMs = dosTimeMs(dosTime);
			if ((flags & 0x1000) !== 0) {
				need(cursor, 2, headerEnd, "RAR4 extended time flags");
				const timeFlags = readUInt16LE(bytes, cursor);
				cursor += 2;
				for (let timeIndex = 0; timeIndex < 4; timeIndex++) {
					const mode = (timeFlags >>> ((3 - timeIndex) * 4)) & 15;
					if ((mode & 8) === 0) continue;
					let timeValue = dosTime;

View on GitHub (pinned to 9690622007)

Solutions

  1. Verify the archive's integrity (re-download / check checksum) — a bad method byte usually means corruption.
  2. Confirm the file actually is RAR4 (magic Rar!\x1a\x07\x00) and not another format misdetected.
  3. Re-create the archive with standard WinRAR/rar settings.
  4. Catch ArchiveError and fall back to an external extractor that may handle the variant.

Example fix

// before: parsing a corrupted file
await records(Bun.file("maybe.rar"))
// after: validate first
$`unrar t maybe.rar` // integrity test before use
Defensive patterns

Strategy: validation

Validate before calling

// verify integrity with an external tool before parsing
const proc = Bun.$`unrar t ${archivePath}`.quiet().nothrow();
if ((await proc).exitCode !== 0) throw new Error("archive failed integrity test");

Try / catch

try {
  const recs = await records(file);
} catch (err) {
  if (err instanceof ArchiveError && /Unsupported RAR4 compression method/.test(err.message)) {
    // treat archive as corrupt; request re-upload
  } else throw err;
}

Prevention

When it happens

Trigger: Calling records() on a corrupted RAR4 file (method byte overwritten), on data misdetected as RAR4, or on archives produced by nonstandard/modified RAR tools.

Common situations: Truncated or bit-rotted downloads; files with wrong extension fed to the reader; experimental RAR forks.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/deeecbf4e7e08e89. Report an issue: GitHub.