{"record":{"id":"b2373577c993fdd5","repo":"can1357/oh-my-pi","slug":"unsupported-rpm-package-lead-version-or-type","errorCode":null,"errorMessage":"Unsupported RPM package lead version or type","messagePattern":"Unsupported RPM package lead version or type","errorType":"validation","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/rpm.ts","lineNumber":250,"sourceCode":"\t\t\treturn zstdDecompress(payload, maxOutput);\n\t\tcase \"lzma\":\n\t\t\tif (!sniffLzmaAlone(payload)) throw new ArchiveError(`RPM package '${identity}' has a malformed LZMA payload`);\n\t\t\treturn lzmaAloneDecompress(payload, maxOutput);\n\t\tcase \"none\":\n\t\t\tif (!sniffCpio(payload))\n\t\t\t\tthrow new ArchiveError(`RPM package '${identity}' has an invalid uncompressed CPIO payload`);\n\t\t\treturn payload;\n\t\tdefault:\n\t\t\tthrow new ArchiveError(`RPM package '${identity}' uses unsupported payload compressor '${method}'`);\n\t}\n}\n\nasync function readRpmArchive(source: ByteSource, options: FormatReadOptions): Promise<ArchiveIndexEntry[]> {\n\tconst initial = await readExact(source, 0, RPM_LEAD_SIZE + RPM_HEADER_INTRO_SIZE, \"lead and signature header\");\n\tif (!sniffRpm(initial)) throw new ArchiveError(\"Invalid RPM package: bad lead magic\");\n\tconst major = initial[4]!;\n\tconst packageType = (initial[6]! << 8) | initial[7]!;\n\tif (major < 3 || packageType > 1) throw new ArchiveError(\"Unsupported RPM package lead version or type\");\n\tconst signatureType = (initial[78]! << 8) | initial[79]!;\n\tif (signatureType !== RPM_SIGNATURE_TYPE_HEADER) {\n\t\tthrow new ArchiveError(`Unsupported RPM signature type ${signatureType}; only header signatures are supported`);\n\t}\n\tconst leadNameEnd = initial.subarray(10, 76).indexOf(0);\n\tconst leadNameBytes = initial.subarray(10, leadNameEnd < 0 ? 76 : 10 + leadNameEnd);\n\tlet leadName = \"unknown package\";\n\ttry {\n\t\tconst decoded = new TextDecoder(\"utf-8\", { fatal: true }).decode(leadNameBytes);\n\t\tif (decoded) leadName = decoded;\n\t} catch {}\n\n\tconst signatureIntro = parseHeaderIntro(initial.subarray(RPM_LEAD_SIZE), options, \"signature\");\n\tconst signatureEnd = RPM_LEAD_SIZE + signatureIntro.totalSize;\n\tconst mainHeaderOffset = align(signatureEnd, 8);\n\tconst signatureBodyAndPadding = await readExact(\n\t\tsource,\n\t\tRPM_LEAD_SIZE + RPM_HEADER_INTRO_SIZE,","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/rpm.ts#L232-L268","documentation":"The lead magic is valid, but the lead's major version (byte 4) is below 3 or the package type (big-endian u16 at offset 6) is greater than 1. The library only supports RPM v3+ binary/source packages (type 0 = binary, 1 = source); anything else — e.g. ancient RPM v1/v2 files or GPG signature blobs — is rejected.","triggerScenarios":"Reading an RPM whose lead byte 4 is 1 or 2 (pre-1997 rpm versions), or whose packageType field is neither 0 nor 1 (e.g. type 2+, non-package artifacts carrying RPM lead magic).","commonSituations":"Working with archival RPMs from RHEL 4-era or older distributions, artifacts like .mst/.hdr metadata files, or mislabeled files that happen to start with RPM lead bytes.","solutions":["Obtain a modern rebuild of the package (rpm v3/v4 format); v1/v2 packages cannot be read here.","Convert old packages on a legacy system or in a container: rpm2cpio the file there and repack as a current RPM.","Confirm with `file <path>` that the artifact is really a binary/source RPM and not an .hdr or metadata blob.","If this is your build pipeline emitting a wrong packageType, fix the rpmbuild invocation."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"async function rpmLeadVersionAndType(path: string): Promise<{ major: number; type: number } | null> {\n  const b = new Uint8Array(await Bun.file(path).slice(0, 8).arrayBuffer());\n  if (b.length < 8) return null;\n  return { major: b[4]!, type: (b[6]! << 8) | b[7]! };\n}\n// require major >= 3 && type <= 1 before reading","typeGuard":"function isSupportedRpmLead(head: Uint8Array): boolean {\n  const major = head[4] ?? 0;\n  const type = ((head[6] ?? 0) << 8) | (head[7] ?? 0);\n  return major >= 3 && type <= 1;\n}","tryCatchPattern":"try {\n  return await readRpm(path);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.includes('lead version or type')) {\n    throw new Error('Only RPM v3+ binary/source packages are supported; convert legacy packages first');\n  }\n  throw err;\n}","preventionTips":["Reject pre-v3 RPMs at ingest; rebuild them on a legacy system if needed.","Ensure the artifact is a package, not an .hdr/metadata blob.","Document supported RPM versions for pipeline consumers."],"tags":["rpm","version-compatibility","unsupported-format","archive"],"backgroundTag":"unsupported-archive-version","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}