can1357/oh-my-pi · error · ArchiveError

Unsupported RAR5 header type ${type}

Error message

Unsupported RAR5 header type ${type}

What it means

parseRar5 encountered a header block whose type number is not one it understands (file=2, service handled via name, main=1, end=5, plus a few skippable types gated by flag bit 4). When the type is unknown AND the header is not marked skippable (flags bit 4 clear), the parser cannot safely advance, so it throws ArchiveError. Unknown non-skippable headers usually mean a newer RAR5 revision or a corrupted stream.

Source

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

						solid,
						crc: dataCrc,
						isDirectory,
						mtimeMs,
						mode: hostOs === 1 ? attributes : undefined,
						linkTarget,
						linkResolveTarget,
					});
					assertEntryCount(records.length, options.limits);
				}
			} else if (rawPath === "RR") {
				throw new ArchiveError("Unsupported RAR5 recovery record");
			}
		} else if (type === 5) {
			const endFlags = readVint(bytes, cursor, extraStart, "end flags");
			if ((endFlags & 1) !== 0) throw new ArchiveError("Unsupported multi-volume RAR5 archive");
			break;
		} else if ((flags & 4) === 0) {
			throw new ArchiveError(`Unsupported RAR5 header type ${type}`);
		}
		offset = dataEnd;
	}
	if (!sawMain) corrupt("RAR5 main header is missing");
	return records;
}

function parseRar4(bytes: Uint8Array, marker: number, options: FormatReadOptions): RarRecord[] {
	const records: RarRecord[] = [];
	let offset = marker + RAR4_MARKER.byteLength;
	let sawMain = false;
	while (offset < bytes.byteLength) {
		need(offset, 7, bytes.byteLength, "RAR4 base header");
		const headerCrc = readUInt16LE(bytes, offset);
		const type = bytes[offset + 2]!;
		const flags = readUInt16LE(bytes, offset + 3);
		const headerSize = readUInt16LE(bytes, offset + 5);
		if (headerSize < 7) corrupt("invalid RAR4 header size");

View on GitHub (pinned to 9690622007)

Solutions

  1. Re-create the archive with a standard RAR5 profile (no exotic service headers: no quick-open .qo, no RR) or as zip/tar.
  2. Verify the file is not corrupted (check its checksum / re-download).
  3. Update the library to a version whose parseRar5 recognizes the new header type.
  4. Catch ArchiveError and fall back to an external RAR extractor for unknown formats.

Example fix

// before
$`rar a -rr -ma5 archive.rar files/` // new service headers
// after
$`rar a archive.rar files/` // plain RAR5, no extra service records
Defensive patterns

Strategy: try-catch

Validate before calling

// sanity: RAR5 magic and plausible size before parse
if (bytes.length < 8 || String.fromCharCode(...bytes.slice(0, 7)) !== "Rar!\x1a\x07\x01\x00") {
  throw new Error("not a RAR5 file");
}

Try / catch

try {
  const recs = await records(file);
} catch (err) {
  if (err instanceof ArchiveError && /Unsupported RAR5 header type/.test(err.message)) {
    // fall back to external extractor or ask user to re-create the archive
  } else throw err;
}

Prevention

When it happens

Trigger: Calling records() on an archive produced by a newer RAR version introducing header types this parser predates, or on corrupted data where the type byte was damaged.

Common situations: Archives created by very recent WinRAR/unrar versions with new service headers; byte-flipped or truncated files misread as RAR; hand-crafted/fuzzed inputs.

Related errors


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