JuliusBrussee/caveman · error
key is required
Error message
${label} key is required What it means
Thrown by decodeReceiptKey when the ReceiptPublicKey's key field is missing, not a string, or an empty/whitespace-only string. Without the base64 key material, the verifier cannot construct a KeyObject and verify receipt signatures.
Solutions
- Provide the base64-encoded 32-byte Ed25519 public key in the key field.
- Regenerate the bundle with the official export command.
- Validate bundle JSON against the receipt bundle schema before verification.
Example fix
// before
{"key_id": "k1", "alg": "Ed25519", "key": ""}
// after
{"key_id": "k1", "alg": "Ed25519", "key": "MCowBQYDK2VwAyEA..."} Defensive patterns
Strategy: validation
Validate before calling
if (typeof info.key !== 'string' || !info.key.trim()) throw new Error('key material required'); Type guard
function hasKeyMaterial(info: unknown): info is { key: string } {
return typeof info === 'object' && info !== null && typeof (info as any).key === 'string' && (info as any).key.trim() !== '';
} Try / catch
try {
verifyBundle(bundle);
} catch (e) {
if ((e as Error).message.includes('key is required')) console.error('bundle key entry has no key material');
throw e;
} Prevention
- Validate bundles against the schema before sharing/verifying.
- Never redact by deleting fields; use a tool that preserves structure.
- Check exported JSON contains no empty-string placeholders.
When it happens
Trigger: Verifying a bundle whose public key entry omits the key field or sets it to "", null, or a non-string value — e.g. hand-edited JSON or a bundle produced with key material stripped.
Common situations: Redacting keys before sharing a bundle and accidentally removing the key field entirely; JSON template placeholders like "<key>" replaced with empty string; a truncated export.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- key_id is required
- bundle completeness cannot be attested by unsigned export…
- canonical span
- cave_agent_definition_invalid
- cave_context_ir_invalid
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/c8ceaf0eed09a3d9.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/index.ts:17850
for (const r of sorted) {
const decoded = keys.get(r.signature?.key_id);
if (!decoded) return `seq ${r.seq}: no trusted public key for key_id ${String(r.signature?.key_id)}`;
const err = verifyReceipt(r, decoded.key, decoded.info.key_id);
if (err) return err;
if (prev) {
if (r.seq !== prev.seq + 1) return `seq ${r.seq}: not strictly after ${prev.seq}`;
if (r.prev_receipt_hash !== prev.receipt_hash) return `seq ${r.seq}: prev_receipt_hash does not link to seq ${prev.seq}`;
if (r.day <= prev.day) return `seq ${r.seq}: day ${r.day} does not follow ${prev.day}`;
}
prev = r;
}
return null;
}
function decodeReceiptKey(info: ReceiptPublicKey, label: string): DecodedReceiptKey {
if (!info || typeof info.key_id !== "string" || !info.key_id.trim()) throw new Error(`${label} key_id is required`);
if (info.alg !== "Ed25519") throw new Error(`${label} has unsupported algorithm ${String(info.alg)}`);
if (typeof info.key !== "string" || !info.key.trim()) throw new Error(`${label} key is required`);
const raw = Buffer.from(info.key, "base64");
if (raw.length !== 32 || raw.toString("base64") !== info.key) throw new Error(`${label} must be a canonical base64 Ed25519 public key`);
return { info, raw, key: ed25519PublicKey(raw) };
}
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)}`);View on GitHub (pinned to 3ee70a1026)