{"record":{"id":"ce9f33acfe81e69f","repo":"can1357/oh-my-pi","slug":"unsupported-rar5-header-type-type","errorCode":null,"errorMessage":"Unsupported RAR5 header type ${type}","messagePattern":"Unsupported RAR5 header type (.+?)","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/rar.ts","lineNumber":446,"sourceCode":"\t\t\t\t\t\tsolid,\n\t\t\t\t\t\tcrc: dataCrc,\n\t\t\t\t\t\tisDirectory,\n\t\t\t\t\t\tmtimeMs,\n\t\t\t\t\t\tmode: hostOs === 1 ? attributes : undefined,\n\t\t\t\t\t\tlinkTarget,\n\t\t\t\t\t\tlinkResolveTarget,\n\t\t\t\t\t});\n\t\t\t\t\tassertEntryCount(records.length, options.limits);\n\t\t\t\t}\n\t\t\t} else if (rawPath === \"RR\") {\n\t\t\t\tthrow new ArchiveError(\"Unsupported RAR5 recovery record\");\n\t\t\t}\n\t\t} else if (type === 5) {\n\t\t\tconst endFlags = readVint(bytes, cursor, extraStart, \"end flags\");\n\t\t\tif ((endFlags & 1) !== 0) throw new ArchiveError(\"Unsupported multi-volume RAR5 archive\");\n\t\t\tbreak;\n\t\t} else if ((flags & 4) === 0) {\n\t\t\tthrow new ArchiveError(`Unsupported RAR5 header type ${type}`);\n\t\t}\n\t\toffset = dataEnd;\n\t}\n\tif (!sawMain) corrupt(\"RAR5 main header is missing\");\n\treturn records;\n}\n\nfunction parseRar4(bytes: Uint8Array, marker: number, options: FormatReadOptions): RarRecord[] {\n\tconst records: RarRecord[] = [];\n\tlet offset = marker + RAR4_MARKER.byteLength;\n\tlet sawMain = false;\n\twhile (offset < bytes.byteLength) {\n\t\tneed(offset, 7, bytes.byteLength, \"RAR4 base header\");\n\t\tconst headerCrc = readUInt16LE(bytes, offset);\n\t\tconst type = bytes[offset + 2]!;\n\t\tconst flags = readUInt16LE(bytes, offset + 3);\n\t\tconst headerSize = readUInt16LE(bytes, offset + 5);\n\t\tif (headerSize < 7) corrupt(\"invalid RAR4 header size\");","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/rar.ts#L428-L464","documentation":"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.","triggerScenarios":"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.","commonSituations":"Archives created by very recent WinRAR/unrar versions with new service headers; byte-flipped or truncated files misread as RAR; hand-crafted/fuzzed inputs.","solutions":["Re-create the archive with a standard RAR5 profile (no exotic service headers: no quick-open .qo, no RR) or as zip/tar.","Verify the file is not corrupted (check its checksum / re-download).","Update the library to a version whose parseRar5 recognizes the new header type.","Catch ArchiveError and fall back to an external RAR extractor for unknown formats."],"exampleFix":"// before\n$`rar a -rr -ma5 archive.rar files/` // new service headers\n// after\n$`rar a archive.rar files/` // plain RAR5, no extra service records","handlingStrategy":"try-catch","validationCode":"// sanity: RAR5 magic and plausible size before parse\nif (bytes.length < 8 || String.fromCharCode(...bytes.slice(0, 7)) !== \"Rar!\\x1a\\x07\\x01\\x00\") {\n  throw new Error(\"not a RAR5 file\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  const recs = await records(file);\n} catch (err) {\n  if (err instanceof ArchiveError && /Unsupported RAR5 header type/.test(err.message)) {\n    // fall back to external extractor or ask user to re-create the archive\n  } else throw err;\n}","preventionTips":["Pin/recreate archives with mainstream WinRAR/rar versions.","Verify file integrity (CRC/checksum) before parsing.","Update the library when new RAR features ship.","Log the offending header type from the message for triage."],"tags":["archive","rar5","unknown-header","format-version"],"backgroundTag":"unsupported-archive-header-type","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}