{"record":{"id":"201ec30f7d4dcf8f","repo":"can1357/oh-my-pi","slug":"encrypted-rar4-headers-are-not-supported","errorCode":null,"errorMessage":"Encrypted RAR4 headers are not supported","messagePattern":"Encrypted RAR4 headers are not supported","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/rar.ts","lineNumber":480,"sourceCode":"\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\");\n\t\tassertIndexSize(headerSize, options.limits, \"RAR4 header\");\n\t\tconst headerEnd = checkedEnd(offset, headerSize, bytes.byteLength, \"RAR4 header\");\n\t\tif ((crc32(bytes.subarray(offset + 2, headerEnd)) & 0xffff) !== headerCrc) corrupt(\"RAR4 header CRC mismatch\");\n\t\tlet dataSize = 0;\n\t\tlet cursor = offset + 7;\n\t\tif ((flags & 0x8000) !== 0) {\n\t\t\tneed(cursor, 4, headerEnd, \"RAR4 additional size\");\n\t\t\tdataSize = readUInt32LE(bytes, cursor);\n\t\t\tcursor += 4;\n\t\t}\n\t\tconst dataStart = headerEnd;\n\t\tlet dataEnd = checkedEnd(dataStart, dataSize, bytes.byteLength, \"RAR4 data area\");\n\t\tif (type === 0x73) {\n\t\t\tif ((flags & 1) !== 0) throw new ArchiveError(\"Unsupported multi-volume RAR4 archive\");\n\t\t\tif ((flags & 0x40) !== 0) throw new ArchiveError(\"Unsupported RAR4 recovery record\");\n\t\t\tif ((flags & 0x80) !== 0) throw new ArchiveError(\"Encrypted RAR4 headers are not supported\");\n\t\t\tsawMain = true;\n\t\t} else if (type === 0x74) {\n\t\t\tneed(cursor, 21, headerEnd, \"RAR4 file header\");\n\t\t\tconst unpackedLow = readUInt32LE(bytes, cursor);\n\t\t\tcursor += 4;\n\t\t\tconst hostOs = bytes[cursor++]!;\n\t\t\tconst dataCrc = readUInt32LE(bytes, cursor);\n\t\t\tcursor += 4;\n\t\t\tconst dosTime = readUInt32LE(bytes, cursor);\n\t\t\tcursor += 4;\n\t\t\tconst version = bytes[cursor++]!;\n\t\t\tconst methodByte = bytes[cursor++]!;\n\t\t\tconst nameSize = readUInt16LE(bytes, cursor);\n\t\t\tcursor += 2;\n\t\t\tconst attributes = readUInt32LE(bytes, cursor);\n\t\t\tcursor += 4;\n\t\t\tlet packedSize = dataSize;\n\t\t\tlet unpackedSize = unpackedLow;","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/rar.ts#L462-L498","documentation":"Flag bit 0x80 on the RAR4 main header (type 0x73) means the archive's header block is encrypted (password-protected file names, set via 'Encrypt file names' in WinRAR). Without the password and AES decryption of headers, no member can even be enumerated, so the parser throws ArchiveError rather than returning garbage.","triggerScenarios":"Calling records() on a RAR4 archive created with header encryption enabled; the throw happens at the very first main header, before any file entries.","commonSituations":"Archives shared with 'Encrypt file names' checked and a password; pipelines missing password handling for legacy RAR4; users assuming filename-only listing works without the password.","solutions":["Decrypt/extract externally with the password (unrar x -p<password> or 7z x -p<password>) and feed the extracted files to the library.","Ask the archive creator to re-create it without header encryption (uncheck 'Encrypt file names').","Repackage decrypted contents as zip/tar.","Catch ArchiveError and prompt the user for a password / route to an external decryption path."],"exampleFix":"// before\nawait records(Bun.file(\"secret.rar\")) // header-encrypted\n// after\n$`unrar x -p$PASS secret.rar out/` // then read out/ files","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const recs = await records(file);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.includes(\"Encrypted RAR4 headers\")) {\n    // obtain password, decrypt via unrar -p<pass>, then reprocess\n  } else throw err;\n}","preventionTips":["Ask archive creators to disable 'Encrypt file names' (header encryption).","Collect the password at intake if encrypted RAR is expected.","Route encrypted RAR4 to unrar/7z with -p before parsing.","Detect the case early: this throws before any entries, so no partial results to clean up."],"tags":["archive","rar4","encryption","password"],"backgroundTag":"encrypted-archive-unsupported","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}