can1357/oh-my-pi · error · ArchiveError
Invalid ARJ archive header
Error message
Invalid ARJ archive header
What it means
This ArchiveError is thrown when sniffArj rejects the input: the data does not begin with the ARJ magic bytes (0x60 0xEA) or the first header fails basic size/CRC checks. The file is simply not a valid ARJ archive as far as this reader can tell.
Source
Thrown at packages/utils/src/ar/arj.ts:239
const body = bytes.subarray(4, 4 + size);
return body[0]! >= 30 && body[0]! <= size && body[6] === 2 && crc32(body) === u32(bytes, 4 + size);
}
/** Index an ARJ archive and lazily decode stored, static-Huffman, and fast-LZSS members. */
export const readArj: FormatReader = async (
source: ByteSource,
options: FormatReadOptions,
): Promise<ArchiveIndexEntry[]> => {
assertInMemorySize(source.size, options.limits);
let bytes: Uint8Array;
try {
bytes = await readAllBytes(source);
} catch (error) {
if (error instanceof ArchiveError) throw error;
throw new ArchiveError(`Unable to read ARJ archive: ${error instanceof Error ? error.message : String(error)}`);
}
if (bytes.byteLength !== source.size) throw new ArchiveError("Invalid ARJ archive: truncated data");
if (!sniffArj(bytes)) throw new ArchiveError("Invalid ARJ archive header");
const main = parseArjBlock(bytes, 0, options);
if (main.isEnd) throw new ArchiveError("Invalid ARJ archive: missing main header");
const mainFirstHeaderSize = bytes[main.bodyStart]!;
if (mainFirstHeaderSize < 30 || mainFirstHeaderSize > main.bodySize || bytes[main.bodyStart + 6] !== 2) {
throw new ArchiveError("Invalid ARJ main header");
}
const mainFlags = bytes[main.bodyStart + 4]!;
if ((mainFlags & 0x01) !== 0) throw new ArchiveError("Encrypted ARJ archives are unsupported");
if ((mainFlags & 0x04) !== 0) throw new ArchiveError("Multi-volume ARJ archives are unsupported");
const entries: ArchiveIndexEntry[] = [];
let offset = main.nextOffset;
let metadataSize = main.metadataSize;
let parsedCount = 0;
for (;;) {
const block = parseArjBlock(bytes, offset, options);
metadataSize += block.metadataSize;View on GitHub (pinned to 9690622007)
Solutions
- Confirm the file is actually an ARJ archive (check magic bytes 0x60 0xEA at offset 0, or run `file archive.arj`).
- If it is an SFX executable, strip the leading executable stub so the ARJ header is at offset 0.
- Re-download the file — the header CRC may be damaged.
- If it is another archive format, use that format's reader instead.
Example fix
// before
const entries = await readArj(source, options);
// after
if (!sniffArj(bytes)) throw new Error(`${path} is not a valid ARJ archive (bad magic/header)`);
const entries = await readArj(source, options); Defensive patterns
Strategy: validation
Validate before calling
const head = new Uint8Array(2);
await fs.read(fd, head, 0, 2, 0);
if (head[0] !== 0x60 || head[1] !== 0xea) {
throw new Error(`${path} is not an ARJ archive (bad magic)`);
} Type guard
function looksLikeArj(bytes: Uint8Array): boolean {
return bytes.byteLength >= 2 && bytes[0] === 0x60 && bytes[1] === 0xea;
} Try / catch
try {
const entries = await readArj(source, options);
} catch (e) {
if (e instanceof ArchiveError && e.message.includes('archive header')) {
throw new Error(`${path} is not a valid ARJ archive; check the format`);
}
throw e;
} Prevention
- Check magic bytes 0x60 0xEA before parsing
- Use `file` or sniffArj to detect actual format instead of trusting extensions
- For SFX executables, locate and slice off the leading stub first
When it happens
Trigger: Calling readArj(source, options) on a file that is not ARJ format (e.g. a ZIP, RAR, or text file), or an ARJ so corrupted that even the signature/header CRC is unreadable.
Common situations: Wrong file extension, renamed files, HTML error pages saved as .arj, zero-byte or placeholder files, SFX (self-extracting) executables with a leading EXE stub.
Related errors
- Invalid CPIO archive: unsupported or corrupt magic at offset
- Invalid ARJ archive: truncated ${what}
- Invalid ARJ header signature
- ARJ member '${memberPath}' has inconsistent stored size
- ARJ member '${memberPath}' has invalid no-data method sizes
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/0452f58a0112399a.
Report an issue: GitHub.