JuliusBrussee/caveman · error
v2 bundle requires public_keys
Error message
v2 bundle requires public_keys
What it means
embeddedReceiptKeys() enforces that schema v2 receipt bundles carry a non-empty `public_keys` array (a rotation keyring). A v2 bundle missing `public_keys`, or with an empty array, is incomplete for verification and is rejected.
Solutions
- Add a non-empty `public_keys` array (must include the key in `public_key`) to the bundle
- Revert the schema field to v1 if the bundle genuinely has only a single key
- Re-export the bundle with `caveman receipts export` so v2 metadata is generated correctly
Example fix
// before
{"schema":"caveman.receipt-bundle/v2","public_key":{...}}
// after
{"schema":"caveman.receipt-bundle/v2","public_key":{...},"public_keys":[{...},{...}]} Defensive patterns
Strategy: validation
Validate before calling
const isV2 = bundle.schema === 'caveman.receipt-bundle/v2';
if (isV2 && (!Array.isArray(bundle.public_keys) || bundle.public_keys.length === 0)) throw new Error('v2 bundle requires public_keys'); Type guard
const validV2 = (b: ReceiptBundle): boolean => b.schema !== 'caveman.receipt-bundle/v2' || (Array.isArray(b.public_keys) && b.public_keys.length > 0);
Try / catch
try { verifyBundle(bundle) } catch (e) { if (e.message === 'v2 bundle requires public_keys') { /* request re-export from publisher */ } else throw e } Prevention
- Do not change the schema string on existing v1 bundles
- Keep exporter and verifier versions in sync
- Round-trip test bundles through verify before publishing
When it happens
Trigger: Verifying a bundle with `schema: "caveman.receipt-bundle/v2"` where `public_keys` is absent, undefined, or `[]`.
Common situations: A v1 bundle hand-upgraded by editing the schema string to v2, an exporter bug that omits the keyring, or truncation when copying bundle JSON between systems.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- public_keys must be an array
- eval evidence line must be a JSON object
- --pubkey JSON must contain public_key or public_keys
- v2 public_keys must include public_key
- assembly slot content is not JSON-serializable
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/1e7189238849e97e.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/index.ts:17872
}
function decodeUniqueKeyring(infos: ReceiptPublicKey[], label: string): Map<string, DecodedReceiptKey> {
const keys = new Map<string, DecodedReceiptKey>();
for (const [index, info] of infos.entries()) {
const decoded = decodeReceiptKey(info, `${label}[${index}]`);
if (keys.has(decoded.info.key_id)) throw new Error(`${label} contains duplicate key_id ${decoded.info.key_id}`);
keys.set(decoded.info.key_id, decoded);
}
return keys;
}
function embeddedReceiptKeys(bundle: ReceiptBundle): { current: DecodedReceiptKey; keys: Map<string, DecodedReceiptKey> } {
if (bundle.schema !== RECEIPT_BUNDLE_V1 && bundle.schema !== RECEIPT_BUNDLE_V2) throw new Error(`unsupported bundle schema ${String(bundle.schema)}`);
if (bundle.verification_coverage !== undefined && bundle.verification_coverage !== INCLUDED_RECEIPTS_ONLY) throw new Error(`unsupported unsigned verification coverage ${String(bundle.verification_coverage)}`);
if (bundle.completeness_attested === true) throw new Error("bundle completeness cannot be attested by unsigned export metadata");
const current = decodeReceiptKey(bundle.public_key, "public_key");
if (bundle.public_keys !== undefined && !Array.isArray(bundle.public_keys)) throw new Error("public_keys must be an array");
if (bundle.schema === RECEIPT_BUNDLE_V2 && (!Array.isArray(bundle.public_keys) || bundle.public_keys.length === 0)) throw new Error("v2 bundle requires public_keys");
const keys = decodeUniqueKeyring(bundle.public_keys ?? [], "public_keys");
const currentInRing = keys.get(current.info.key_id);
if (currentInRing && !currentInRing.raw.equals(current.raw)) throw new Error(`public_key conflicts with public_keys entry ${current.info.key_id}`);
if (bundle.schema === RECEIPT_BUNDLE_V2 && !currentInRing) throw new Error("v2 public_keys must include public_key");
if (!currentInRing) keys.set(current.info.key_id, current);
return { current, keys };
}
async function pinnedReceiptKeys(file: string, current: DecodedReceiptKey): Promise<{ keys: Map<string, DecodedReceiptKey>; trust: string }> {
const source = (await readFile(file, "utf8")).trim();
if (!source.startsWith("{")) {
const pinned = decodeReceiptKey({ ...current.info, key: source }, "--pubkey");
if (!pinned.raw.equals(current.raw)) throw new Error("bundle public key does not match the published --pubkey");
return { keys: new Map([[current.info.key_id, pinned]]), trust: "pinned_public_key" };
}
let parsed: { public_key?: ReceiptPublicKey; public_keys?: ReceiptPublicKey[] };
try { parsed = JSON.parse(source); } catch { throw new Error("--pubkey JSON is malformed"); }
const infos = Array.isArray(parsed.public_keys) ? parsed.public_keys : parsed.public_key ? [parsed.public_key] : [];View on GitHub (pinned to 3ee70a1026)