{"record":{"id":"12f4fe53ddb170f6","repo":"can1357/oh-my-pi","slug":"encrypted-rar4-file-data-is-not-supported","errorCode":null,"errorMessage":"Encrypted RAR4 file data is not supported","messagePattern":"Encrypted RAR4 file data is not supported","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/rar.ts","lineNumber":508,"sourceCode":"\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;\n\t\t\tif ((flags & 0x100) !== 0) {\n\t\t\t\tneed(cursor, 8, headerEnd, \"RAR4 high sizes\");\n\t\t\t\tpackedSize += readUInt32LE(bytes, cursor) * 0x100000000;\n\t\t\t\tcursor += 4;\n\t\t\t\tunpackedSize += readUInt32LE(bytes, cursor) * 0x100000000;\n\t\t\t\tcursor += 4;\n\t\t\t\tdataEnd = checkedEnd(dataStart, packedSize, bytes.byteLength, \"RAR4 file data\");\n\t\t\t}\n\t\t\tif ((flags & 3) !== 0) throw new ArchiveError(\"Unsupported multi-volume RAR4 member\");\n\t\t\tif ((flags & 4) !== 0) throw new ArchiveError(\"Encrypted RAR4 file data is not supported\");\n\t\t\tif (methodByte < 0x30 || methodByte > 0x35)\n\t\t\t\tthrow new ArchiveError(`Unsupported RAR4 compression method 0x${methodByte.toString(16)}`);\n\t\t\tassertArchivePathBytes(nameSize, \"member path\", options.limits.maxPathBytes);\n\t\t\tneed(cursor, nameSize, headerEnd, \"RAR4 file name\");\n\t\t\tconst nameBytes = bytes.subarray(cursor, cursor + nameSize);\n\t\t\tconst rawPath = (flags & 0x200) !== 0 ? decodeRar4UnicodeName(nameBytes) : LATIN1.decode(nameBytes);\n\t\t\tcursor += nameSize;\n\t\t\tif ((flags & 0x400) !== 0) {\n\t\t\t\tneed(cursor, 8, headerEnd, \"RAR4 salt\");\n\t\t\t\tcursor += 8;\n\t\t\t}\n\t\t\tlet mtimeMs = dosTimeMs(dosTime);\n\t\t\tif ((flags & 0x1000) !== 0) {\n\t\t\t\tneed(cursor, 2, headerEnd, \"RAR4 extended time flags\");\n\t\t\t\tconst timeFlags = readUInt16LE(bytes, cursor);\n\t\t\t\tcursor += 2;\n\t\t\t\tfor (let timeIndex = 0; timeIndex < 4; timeIndex++) {\n\t\t\t\t\tconst mode = (timeFlags >>> ((3 - timeIndex) * 4)) & 15;","sourceCodeStart":490,"sourceCodeEnd":526,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/rar.ts#L490-L526","documentation":"Flag bit 2 (0x4) on a RAR4 file header marks the member's packed data as encrypted with a password (AES). The library does not implement RAR crypto decryption, so any encrypted member causes an immediate ArchiveError. Non-encrypted members in the same archive can still be parsed only if no encrypted member is hit first in header order.","triggerScenarios":"Calling records() on a password-protected RAR4 archive (WinRAR 'Set password'); throws at the first encrypted file header during enumeration.","commonSituations":"User-supplied archives protected with a password; CI pipelines lacking the password; archives where only some members are encrypted.","solutions":["Decrypt externally with the password: unrar x -p<password> or 7z x -p<password>, then process the extracted files.","Have the archive creator re-pack without a password.","Repackage decrypted content as zip/tar.","Catch ArchiveError and prompt for a password, routing to an external decryption path."],"exampleFix":"// before\nawait records(Bun.file(\"locked.rar\"))\n// after\n$`7z x -p$PASS locked.rar -oout/` // then read out/","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 file data\")) {\n    // decrypt with password via external tool, then reprocess\n  } else throw err;\n}","preventionTips":["Require unencrypted archives or collect passwords at intake.","Decrypt with unrar x -p<password> before parsing.","Consider converting password-protected content to your own encrypted storage format.","Note: partial parsing stops at the first encrypted member — treat any RAR4 from users as potentially encrypted."],"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"}