can1357/oh-my-pi · error · ArchiveError

Invalid RPM package: tag

Error message

Invalid RPM package: tag ${tag} uses unknown data type ${type}

What it means

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.

Solutions

  1. Confirm the input is actually an RPM (check lead magic 0xEDABEEDB and format with `rpm -qp`).
  2. Re-download the package — an unknown type usually means corruption or a non-RPM file.
  3. If produced by internal tooling, ensure it emits only standard RPM type codes 0-9.
  4. Catch ArchiveError and route the file to a different archive reader.

Example fix

// before: assuming any sniffed file is parseable
const entries = await readRpm(source, options);
// after: pre-check magic and handle rejection
if (!sniffRpm(bytes)) throw new Error("not an RPM file");
try { entries = await readRpm(source, options); }
catch (e) { if (e instanceof ArchiveError) return null; throw e; }
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure the file is really an RPM before dispatching to the RPM reader
if (!sniffRpm(bytes.subarray(0, 96))) throw new Error("not an RPM");

Try / catch

try {
  return await readRpm(source, options);
} catch (err) {
  if (err instanceof ArchiveError && err.message.includes("unknown data type")) {
    return tryOtherArchiveReaders(source, options);
  }
  throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/a42408cbdee64192. Report an issue: GitHub.

Appendix: source

Thrown at packages/utils/src/ar/rpm.ts:110

			const stringCount = type === RPM_TYPE_STRING ? 1 : count;
			if (type === RPM_TYPE_STRING && count !== 1) {
				throw new ArchiveError(`Invalid RPM package: string tag ${tag} has an invalid count`);
			}
			if (stringCount > remaining) {
				throw new ArchiveError(`Invalid RPM package: string tag ${tag} exceeds header data`);
			}
			let cursor = indexSize + offset;
			const limit = indexSize + intro.dataSize;
			for (let stringIndex = 0; stringIndex < stringCount; stringIndex++) {
				while (cursor < limit && body[cursor] !== 0) cursor++;
				if (cursor === limit) {
					throw new ArchiveError(`Invalid RPM package: string tag ${tag} is not NUL-terminated`);
				}
				cursor++;
			}
			continue;
		} else {
			throw new ArchiveError(`Invalid RPM package: tag ${tag} uses unknown data type ${type}`);
		}
		if (offset % elementSize !== 0) throw new ArchiveError(`Invalid RPM package: tag ${tag} data is misaligned`);
		if (count * elementSize > remaining)
			throw new ArchiveError(`Invalid RPM package: tag ${tag} exceeds header data`);
	}
}

function readHeaderString(
	body: Uint8Array,
	indexSize: number,
	dataSize: number,
	offset: number,
	count: number,
	type: number,
	tag: number,
): string {
	if (type !== RPM_TYPE_STRING || count !== 1) {
		throw new ArchiveError(`Invalid RPM package: tag ${tag} must contain one string`);

View on GitHub (pinned to 9690622007)