{"record":{"id":"a42408cbdee64192","repo":"can1357/oh-my-pi","slug":"invalid-rpm-package-tag-tag-uses-unknown-data","errorCode":null,"errorMessage":"Invalid RPM package: tag ${tag} uses unknown data type ${type}","messagePattern":"Invalid RPM package: tag (.+?) uses unknown data type (.+?)","errorType":"validation","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/rpm.ts","lineNumber":110,"sourceCode":"\t\t\tconst stringCount = type === RPM_TYPE_STRING ? 1 : count;\n\t\t\tif (type === RPM_TYPE_STRING && count !== 1) {\n\t\t\t\tthrow new ArchiveError(`Invalid RPM package: string tag ${tag} has an invalid count`);\n\t\t\t}\n\t\t\tif (stringCount > remaining) {\n\t\t\t\tthrow new ArchiveError(`Invalid RPM package: string tag ${tag} exceeds header data`);\n\t\t\t}\n\t\t\tlet cursor = indexSize + offset;\n\t\t\tconst limit = indexSize + intro.dataSize;\n\t\t\tfor (let stringIndex = 0; stringIndex < stringCount; stringIndex++) {\n\t\t\t\twhile (cursor < limit && body[cursor] !== 0) cursor++;\n\t\t\t\tif (cursor === limit) {\n\t\t\t\t\tthrow new ArchiveError(`Invalid RPM package: string tag ${tag} is not NUL-terminated`);\n\t\t\t\t}\n\t\t\t\tcursor++;\n\t\t\t}\n\t\t\tcontinue;\n\t\t} else {\n\t\t\tthrow new ArchiveError(`Invalid RPM package: tag ${tag} uses unknown data type ${type}`);\n\t\t}\n\t\tif (offset % elementSize !== 0) throw new ArchiveError(`Invalid RPM package: tag ${tag} data is misaligned`);\n\t\tif (count * elementSize > remaining)\n\t\t\tthrow new ArchiveError(`Invalid RPM package: tag ${tag} exceeds header data`);\n\t}\n}\n\nfunction readHeaderString(\n\tbody: Uint8Array,\n\tindexSize: number,\n\tdataSize: number,\n\toffset: number,\n\tcount: number,\n\ttype: number,\n\ttag: number,\n): string {\n\tif (type !== RPM_TYPE_STRING || count !== 1) {\n\t\tthrow new ArchiveError(`Invalid RPM package: tag ${tag} must contain one string`);","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/rpm.ts#L92-L128","documentation":"Each RPM header index entry carries a data type (NULL=0, CHAR=1, INT8=2, INT16=3, INT32=4, INT64=5, STRING=6, BIN=7, string array=8, I18N string=9). This parser only supports those types; if an entry declares a type outside that set, the header uses an extension or is corrupt, so validation fails immediately.","triggerScenarios":"readRpm()/parseMainHeader reads an index entry whose type field is not one of 0–9 — e.g. garbage bytes interpreted as an index, or a package written by non-standard tooling using a custom type id.","commonSituations":"Files that passed the 4-byte lead magic sniff but are not valid RPMs (e.g. wrong file handed to readRpm); corruption in the index region; hypothetical future/proprietary RPM type codes.","solutions":["Confirm the input is actually an RPM (check lead magic 0xEDABEEDB and format with `rpm -qp`).","Re-download the package — an unknown type usually means corruption or a non-RPM file.","If produced by internal tooling, ensure it emits only standard RPM type codes 0-9.","Catch ArchiveError and route the file to a different archive reader."],"exampleFix":"// before: assuming any sniffed file is parseable\nconst entries = await readRpm(source, options);\n// after: pre-check magic and handle rejection\nif (!sniffRpm(bytes)) throw new Error(\"not an RPM file\");\ntry { entries = await readRpm(source, options); }\ncatch (e) { if (e instanceof ArchiveError) return null; throw e; }","handlingStrategy":"try-catch","validationCode":"// Ensure the file is really an RPM before dispatching to the RPM reader\nif (!sniffRpm(bytes.subarray(0, 96))) throw new Error(\"not an RPM\");","typeGuard":null,"tryCatchPattern":"try {\n  return await readRpm(source, options);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.includes(\"unknown data type\")) {\n    return tryOtherArchiveReaders(source, options);\n  }\n  throw err;\n}","preventionTips":["Route files by content sniffing (sniffRpm) rather than file extension alone.","Only feed standard rpmbuild-produced packages to the reader.","Log the offending file for analysis when an unknown type appears."],"tags":["rpm","archive","unknown-type","header-validation"],"backgroundTag":"rpm-header-validation-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}