{"record":{"id":"60d4212857b20279","repo":"can1357/oh-my-pi","slug":"invalid-rpm-package-tag-tag-is-not-valid-utf-8","errorCode":null,"errorMessage":"Invalid RPM package: tag ${tag} is not valid UTF-8","messagePattern":"Invalid RPM package: tag (.+?) is not valid UTF-8","errorType":"validation","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/rpm.ts","lineNumber":139,"sourceCode":"\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`);\n\t}\n\tconst start = indexSize + offset;\n\tconst limit = indexSize + dataSize;\n\tlet end = start;\n\twhile (end < limit && body[end] !== 0) end++;\n\tif (end === limit) throw new ArchiveError(`Invalid RPM package: tag ${tag} string is not NUL-terminated`);\n\tif (end - start > 4096) throw new ArchiveError(`Invalid RPM package: tag ${tag} string is too large`);\n\ttry {\n\t\treturn UTF8_FATAL_DECODER.decode(body.subarray(start, end));\n\t} catch {\n\t\tthrow new ArchiveError(`Invalid RPM package: tag ${tag} is not valid UTF-8`);\n\t}\n}\n\nfunction parseMainHeader(body: Uint8Array, intro: HeaderIntro): RpmMetadata {\n\tvalidateHeaderBody(body, intro, \"main\");\n\tconst indexSize = intro.indexCount * RPM_INDEX_ENTRY_SIZE;\n\tif (body.byteLength !== intro.bodySize) throw new ArchiveError(\"Invalid RPM package: truncated main header\");\n\tconst metadata: RpmMetadata = {};\n\tfor (let index = 0; index < intro.indexCount; index++) {\n\t\tconst recordOffset = index * RPM_INDEX_ENTRY_SIZE;\n\t\tconst tag = readUInt32BE(body, recordOffset);\n\t\tconst type = readUInt32BE(body, recordOffset + 4);\n\t\tconst offset = readUInt32BE(body, recordOffset + 8);\n\t\tconst count = readUInt32BE(body, recordOffset + 12);\n\t\tif (offset > intro.dataSize) throw new ArchiveError(`Invalid RPM package: tag ${tag} points outside header data`);\n\t\tif (\n\t\t\ttag !== RPM_TAG_NAME &&\n\t\t\ttag !== RPM_TAG_VERSION &&","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/rpm.ts#L121-L157","documentation":"The parser decodes string tag values with a fatal-mode UTF-8 TextDecoder; invalid byte sequences throw and are rethrown as this ArchiveError. RPM metadata strings should be UTF-8 (traditionally ASCII/Latin-1 in old packages), so non-UTF-8 bytes indicate either a corrupt value or a legacy package with raw 8-bit encoding.","triggerScenarios":"readHeaderString successfully finds a NUL-terminated, <=4096-byte value for a known tag, but UTF8_FATAL_DECODER.decode fails on the bytes — e.g. a NAME containing invalid sequences like 0xFF.","commonSituations":"Very old RPM packages built with locale-specific encodings (ISO-8859-1 metadata) instead of UTF-8; corruption of string bytes; packages with binary junk injected into metadata fields.","solutions":["Rebuild or re-download the package; prefer packages built with modern rpmbuild that emit UTF-8 metadata.","If you control the package, convert its metadata (Summary/Description/Name) to valid UTF-8.","Confirm corruption vs. legacy encoding using `rpm -qp` which may render legacy encodings.","Catch ArchiveError around readRpm and either skip the package or retry with a transcoding preprocessor if you must support legacy packages."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await readRpm(source, options);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.includes(\"not valid UTF-8\")) {\n    return rejectPackage(\"RPM metadata is not UTF-8 (legacy encoding or corruption)\");\n  }\n  throw err;\n}","preventionTips":["Prefer packages built with modern tooling that writes UTF-8 metadata.","Rebuild legacy ISO-8859-1 packages with UTF-8 locales before parsing.","Verify checksums to distinguish corruption from legacy encodings."],"tags":["rpm","archive","utf-8","encoding"],"backgroundTag":"rpm-header-validation-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}