{"record":{"id":"54ce6785e83cda3f","repo":"can1357/oh-my-pi","slug":"rar5-member-with-unknown-unpacked-size-is-not-supp","errorCode":null,"errorMessage":"RAR5 member with unknown unpacked size is not supported","messagePattern":"RAR5 member with unknown unpacked size is not supported","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/rar.ts","lineNumber":342,"sourceCode":"\t\tconst extraSize = (flags & 1) !== 0 ? readVint(bytes, cursor, headerEnd, \"extra area size\") : 0;\n\t\tconst dataSize = (flags & 2) !== 0 ? readVint(bytes, cursor, headerEnd, \"data size\") : 0;\n\t\tif ((flags & 0x18) !== 0) throw new ArchiveError(\"Unsupported multi-volume RAR5 archive\");\n\t\tconst dataStart = headerEnd;\n\t\tconst dataEnd = checkedEnd(dataStart, dataSize, bytes.byteLength, \"RAR5 data area\");\n\t\tif (extraSize > headerEnd - cursor.offset) corrupt(\"invalid RAR5 extra area size\");\n\t\tconst extraStart = headerEnd - extraSize;\n\n\t\tif (type === 4) throw new ArchiveError(\"Encrypted RAR5 headers are not supported\");\n\t\tif (type === 1) {\n\t\t\tconst archiveFlags = readVint(bytes, cursor, extraStart, \"archive flags\");\n\t\t\tif ((archiveFlags & 1) !== 0) throw new ArchiveError(\"Unsupported multi-volume RAR5 archive\");\n\t\t\tif ((archiveFlags & 8) !== 0) throw new ArchiveError(\"Unsupported RAR5 recovery record\");\n\t\t\tif ((archiveFlags & 2) !== 0) readVint(bytes, cursor, extraStart, \"volume number\");\n\t\t\tsawMain = true;\n\t\t} else if (type === 2 || type === 3) {\n\t\t\tconst fileFlags = readVint(bytes, cursor, extraStart, \"file flags\");\n\t\t\tconst unpackedSize = readVint(bytes, cursor, extraStart, \"unpacked size\");\n\t\t\tif ((fileFlags & 8) !== 0) throw new ArchiveError(\"RAR5 member with unknown unpacked size is not supported\");\n\t\t\tconst attributes = readVint(bytes, cursor, extraStart, \"file attributes\");\n\t\t\tlet mtimeMs: number | undefined;\n\t\t\tif ((fileFlags & 2) !== 0) {\n\t\t\t\tneed(cursor.offset, 4, extraStart, \"RAR5 modification time\");\n\t\t\t\tmtimeMs = readUInt32LE(bytes, cursor.offset) * 1000;\n\t\t\t\tcursor.offset += 4;\n\t\t\t}\n\t\t\tlet dataCrc: number | undefined;\n\t\t\tif ((fileFlags & 4) !== 0) {\n\t\t\t\tneed(cursor.offset, 4, extraStart, \"RAR5 data CRC32\");\n\t\t\t\tdataCrc = readUInt32LE(bytes, cursor.offset);\n\t\t\t\tcursor.offset += 4;\n\t\t\t}\n\t\t\tconst compression = readVint(bytes, cursor, extraStart, \"compression information\");\n\t\t\tlet version = compression & 0x3f;\n\t\t\tif (version === 1 && (compression & 0x100000) !== 0) version = 0;\n\t\t\tconst solid = (compression & 0x40) !== 0;\n\t\t\tconst method = (compression >>> 7) & 7;","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/rar.ts#L324-L360","documentation":"RAR5 file header flag bit 8 (UNPACKED_SIZE_UNKNOWN) indicates the member's unpacked size was not stored — the decoder must discover it while decompressing (streaming mode). This library needs the size up front to bound memory and validate limits, so it rejects such members.","triggerScenarios":"Parsing a RAR5 archive whose file/dir header (type 2 or 3) has fileFlags bit 0x8 set, typically produced by streaming/piped compression where the size is unknown at header write time.","commonSituations":"Archives generated by tools piping data into rar (`tar c | rar a -si`), which omits sizes; unusual third-party RAR writers; archives rebuilt by scripts that stream content.","solutions":["Re-create the archive from files on disk so sizes are stored (avoid `-si` streaming input)","Extract with the unrar CLI and re-compress normally","Inspect the offending member with `unrar l -v` to identify the streaming-produced entry"],"exampleFix":"// before\ntar c dir/ | rar a -si archive.rar   # unknown sizes -> rejected\n// after\nrar a archive.rar dir/               # sizes stored in headers","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const records = readRar(bytes);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.includes('unknown unpacked size')) {\n    // re-extract via unrar CLI which supports streaming members\n  } else throw err;\n}","preventionTips":["Avoid `rar a -si` (stdin streaming) when archives will be parsed programmatically","Always compress from real files so sizes are recorded in headers"],"tags":["rar5","streaming","unsupported-feature","size-limit"],"backgroundTag":"unsupported-archive-feature","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}