{"record":{"id":"9ef5d6e8a35cc1c0","repo":"can1357/oh-my-pi","slug":"unsupported-rar4-recovery-record","errorCode":null,"errorMessage":"Unsupported RAR4 recovery record","messagePattern":"Unsupported RAR4 recovery record","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/rar.ts","lineNumber":479,"sourceCode":"\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\");\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;","sourceCodeStart":461,"sourceCodeEnd":497,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/rar.ts#L461-L497","documentation":"The RAR4 main header (type 0x73) with flag bit 0x40 indicates an auxiliary recovery record attached to the archive. parseRar4 does not implement recovery records, so it refuses the archive with ArchiveError. Like the RAR5 RR case, recovery data is repair redundancy, not file content.","triggerScenarios":"Calling records() on a RAR4 archive created with 'Add recovery record' enabled (WinRAR -rr, flag 0x40 in the main header).","commonSituations":"Legacy archives distributed with recovery data for usenet/email transfer; archives protected against bit-rot by the sender; re-shared archives that kept the flag.","solutions":["Re-create the archive without a recovery record (omit -rr in rar).","Open and re-save the archive in WinRAR with recovery record removed.","Extract with unrar/7-Zip externally and repackage as zip/tar for this library.","Catch ArchiveError and fall back to an external extractor."],"exampleFix":"// before\n$`rar a -rr archive.rar files/`\n// after\n$`rar a archive.rar files/`","handlingStrategy":"try-catch","validationCode":"// Cannot read the main-header flags before parsing; guard by re-packing policy:\n// if archives come from an untrusted source, test-parse and handle ArchiveError.","typeGuard":null,"tryCatchPattern":"try {\n  const recs = await records(file);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.includes(\"RAR4 recovery record\")) {\n    // strip recovery record via WinRAR or extract externally\n  } else throw err;\n}","preventionTips":["Document that -rr archives are unsupported; disable recovery records at creation.","Normalize incoming archives (repack to zip/tar) at intake.","Keep an external extractor fallback.","Surface the flag name from the message to users."],"tags":["archive","rar4","recovery-record","unsupported-feature"],"backgroundTag":"unsupported-archive-feature","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}