{"record":{"id":"cfbb6bfb77eb20e9","repo":"ruvnet/ruflo","slug":"failed-to-parse-rvfa-header-json-cfbb6b","errorCode":null,"errorMessage":"Failed to parse RVFA header JSON","messagePattern":"Failed to parse RVFA header JSON","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/appliance/rvfa-signing.ts","lineNumber":191,"sourceCode":"  const magic = buf.subarray(0, 4).toString('ascii');\n  if (magic !== 'RVFA') {\n    throw new Error(`Invalid RVFA magic: expected \"RVFA\", got \"${magic}\"`);\n  }\n\n  const headerLen = buf.readUInt32LE(8);\n  const headerStart = PREAMBLE_SIZE;\n  const headerEnd = headerStart + headerLen;\n\n  if (headerEnd > buf.length - SHA256_SIZE) {\n    throw new Error('Header length extends beyond buffer');\n  }\n\n  const headerJson = buf.subarray(headerStart, headerEnd).toString('utf-8');\n  let header: Record<string, unknown>;\n  try {\n    header = JSON.parse(headerJson) as Record<string, unknown>;\n  } catch {\n    throw new Error('Failed to parse RVFA header JSON');\n  }\n\n  const footer = buf.subarray(buf.length - SHA256_SIZE);\n  const sectionData = buf.subarray(headerEnd, buf.length - SHA256_SIZE);\n\n  return { header, headerStart, headerEnd, sectionData, footer };\n}\n\n/**\n * Compute the signing digest for an RVFA file.\n *\n * The digest is SHA256 of: canonical_header_json (without signature field)\n *                         + section_data_bytes\n *                         + footer_32_bytes\n */\nfunction computeSigningDigest(\n  header: Record<string, unknown>,\n  sectionData: Buffer,","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/appliance/rvfa-signing.ts#L173-L209","documentation":"Thrown when the header region declared by the preamble is not valid JSON. The framing is intact but the header payload itself is malformed or in a different serialization.","triggerScenarios":"headerLen is consistent with the file but the bytes between headerStart and headerEnd fail JSON.parse: encoding mismatch (UTF-16 vs UTF-8), truncation within the header, or a writer that emits a binary header.","commonSituations":"Writer and reader use different RVFA header formats; header partially overwritten; writer version skew.","solutions":["Confirm writer and reader share the same RVFA version (JSON header).","Re-build the image with a known-good writer.","Inspect the header bytes to confirm UTF-8 JSON content."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const headerJson = buf.subarray(headerStart, headerEnd).toString('utf-8');\ntry {\n  JSON.parse(headerJson);\n} catch {\n  throw new Error('RVFA header region is not valid UTF-8 JSON; check writer version');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin writer and reader to compatible RVFA header versions.","Treat the header as a versioned schema, not free-form JSON.","Log the first N header bytes on failure for forensics."],"tags":["rvfa-signing","json","header","integrity"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}