{"record":{"id":"134b09af7428f7c0","repo":"JuliusBrussee/caveman","slug":"unsupported-bundle-schema-string-bundle-schema","errorCode":null,"errorMessage":"unsupported bundle schema ${String(bundle.schema)}","messagePattern":"unsupported bundle schema (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":17867,"sourceCode":"  if (info.alg !== \"Ed25519\") throw new Error(`${label} has unsupported algorithm ${String(info.alg)}`);\n  if (typeof info.key !== \"string\" || !info.key.trim()) throw new Error(`${label} key is required`);\n  const raw = Buffer.from(info.key, \"base64\");\n  if (raw.length !== 32 || raw.toString(\"base64\") !== info.key) throw new Error(`${label} must be a canonical base64 Ed25519 public key`);\n  return { info, raw, key: ed25519PublicKey(raw) };\n}\n\nfunction decodeUniqueKeyring(infos: ReceiptPublicKey[], label: string): Map<string, DecodedReceiptKey> {\n  const keys = new Map<string, DecodedReceiptKey>();\n  for (const [index, info] of infos.entries()) {\n    const decoded = decodeReceiptKey(info, `${label}[${index}]`);\n    if (keys.has(decoded.info.key_id)) throw new Error(`${label} contains duplicate key_id ${decoded.info.key_id}`);\n    keys.set(decoded.info.key_id, decoded);\n  }\n  return keys;\n}\n\nfunction embeddedReceiptKeys(bundle: ReceiptBundle): { current: DecodedReceiptKey; keys: Map<string, DecodedReceiptKey> } {\n  if (bundle.schema !== RECEIPT_BUNDLE_V1 && bundle.schema !== RECEIPT_BUNDLE_V2) throw new Error(`unsupported bundle schema ${String(bundle.schema)}`);\n  if (bundle.verification_coverage !== undefined && bundle.verification_coverage !== INCLUDED_RECEIPTS_ONLY) throw new Error(`unsupported unsigned verification coverage ${String(bundle.verification_coverage)}`);\n  if (bundle.completeness_attested === true) throw new Error(\"bundle completeness cannot be attested by unsigned export metadata\");\n  const current = decodeReceiptKey(bundle.public_key, \"public_key\");\n  if (bundle.public_keys !== undefined && !Array.isArray(bundle.public_keys)) throw new Error(\"public_keys must be an array\");\n  if (bundle.schema === RECEIPT_BUNDLE_V2 && (!Array.isArray(bundle.public_keys) || bundle.public_keys.length === 0)) throw new Error(\"v2 bundle requires public_keys\");\n  const keys = decodeUniqueKeyring(bundle.public_keys ?? [], \"public_keys\");\n  const currentInRing = keys.get(current.info.key_id);\n  if (currentInRing && !currentInRing.raw.equals(current.raw)) throw new Error(`public_key conflicts with public_keys entry ${current.info.key_id}`);\n  if (bundle.schema === RECEIPT_BUNDLE_V2 && !currentInRing) throw new Error(\"v2 public_keys must include public_key\");\n  if (!currentInRing) keys.set(current.info.key_id, current);\n  return { current, keys };\n}\n\nasync function pinnedReceiptKeys(file: string, current: DecodedReceiptKey): Promise<{ keys: Map<string, DecodedReceiptKey>; trust: string }> {\n  const source = (await readFile(file, \"utf8\")).trim();\n  if (!source.startsWith(\"{\")) {\n    const pinned = decodeReceiptKey({ ...current.info, key: source }, \"--pubkey\");\n    if (!pinned.raw.equals(current.raw)) throw new Error(\"bundle public key does not match the published --pubkey\");","sourceCodeStart":17849,"sourceCodeEnd":17885,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L17849-L17885","documentation":"Thrown by embeddedReceiptKeys when the receipt bundle's schema field is neither RECEIPT_BUNDLE_V1 nor RECEIPT_BUNDLE_V2. The verifier only understands those two bundle formats; anything else (newer format from a newer CLI, older/unknown format, or a corrupted schema value) is rejected before any key decoding.","triggerScenarios":"Verifying a bundle exported by a newer tool version with a schema like 'receipt.bundle.v3', a bundle with a missing/garbled schema field (String(undefined) => 'undefined'), or a hand-crafted test bundle.","commonSituations":"Upgrading the producing tool ahead of the verifying CLI; downgrading the CLI below the bundle version; editing bundle JSON and breaking the schema string.","solutions":["Upgrade the CLI to a version that supports the bundle's schema version.","Re-export the bundle with a schema version the verifier supports (v1/v2).","Print the bundle's schema field and confirm it is exactly the expected version string.","If schema is undefined, the JSON was mangled — re-export rather than hand-edit."],"exampleFix":"// before\n{\"schema\": \"receipt.bundle.v3\", ...}\n// after\n{\"schema\": \"receipt.bundle.v2\", ...} // or upgrade the verifying CLI","handlingStrategy":"validation","validationCode":"const SUPPORTED = ['receipt.bundle.v1', 'receipt.bundle.v2'];\nif (!SUPPORTED.includes(bundle.schema)) throw new Error(`unsupported schema ${bundle.schema}; upgrade the CLI`);","typeGuard":"function isSupportedBundleSchema(b: { schema: unknown }): boolean {\n  return b.schema === 'receipt.bundle.v1' || b.schema === 'receipt.bundle.v2';\n}","tryCatchPattern":"try {\n  verifyBundle(bundle);\n} catch (e) {\n  if ((e as Error).message.includes('unsupported bundle schema')) console.error('upgrade the verifying CLI or re-export with v1/v2');\n  process.exitCode = 1;\n}","preventionTips":["Keep producer and verifier CLI versions aligned.","Check bundle schema before running verification in CI.","Never hand-edit the schema field; re-export instead."],"tags":["versioning","schema","compatibility"],"backgroundTag":"unsupported-enum-value","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}