can1357/oh-my-pi · error · ArchiveError
Invalid ARJ archive: missing main header
Error message
Invalid ARJ archive: missing main header
What it means
This ArchiveError is thrown when the first block parsed from the archive reports isEnd — meaning the parser hit the end-of-archive marker (bodySize 0) immediately, with no main header present. A valid ARJ must start with a main (archive) header before any local file headers.
Source
Thrown at packages/utils/src/ar/arj.ts:242
/** 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;
assertIndexSize(metadataSize, options.limits, "index");
if (block.isEnd) break;
assertEntryCount(++parsedCount, options.limits);View on GitHub (pinned to 9690622007)
Solutions
- The archive has no content headers; obtain a complete archive from the source.
- Verify the file against the original byte size/checksum to detect truncation.
- Re-create the archive; if the producer intentionally made an empty archive, it is still not readable as a member-bearing ARJ by this reader.
Example fix
// before
const entries = await readArj(source, options);
// after
try {
const entries = await readArj(source, options);
if (entries.length === 0) console.warn('archive contains no members');
} catch (e) {
if (e instanceof ArchiveError && e.message.includes('missing main header')) {
throw new Error('archive is empty or its main header is missing; re-acquire the file');
}
throw e;
} Defensive patterns
Strategy: validation
Validate before calling
if (stat.size < 34) throw new Error(`${path} is too small to be a member-bearing ARJ archive`); Try / catch
try {
const entries = await readArj(source, options);
} catch (e) {
if (e instanceof ArchiveError && e.message.includes('missing main header')) {
throw new Error('archive is empty or its main header is missing; re-acquire it');
}
throw e;
} Prevention
- Reject archives smaller than the minimum main-header size (~34 bytes) up front
- Compare file size against the original source to detect truncation
- Treat zero-content archives as invalid input rather than empty results
When it happens
Trigger: Calling readArj on data whose very first block after the signature is an end marker — e.g. an empty/headerless archive, or corruption that zeroed the main header size field.
Common situations: Zero-length archives created by aborted archiver runs, severely truncated/corrupted files, files that only consist of the two signature bytes plus terminator.
Related errors
- Invalid ARJ main header
- ARJ member '${memberPath}' has inconsistent stored size
- ARJ member '${memberPath}' has invalid no-data method sizes
- ARJ member '${memberPath}' extracted to an unexpected size
- ARJ member '${memberPath}' failed CRC32 verification
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/38024039c19a5ce4.
Report an issue: GitHub.