{"record":{"id":"c8a03f032945d50d","repo":"ruvnet/ruflo","slug":"invalid-rvfa-magic-expected-rvfa-got-magic-c8a03f","errorCode":null,"errorMessage":"Invalid RVFA magic: expected \"RVFA\", got \"${magic}\"","messagePattern":"Invalid RVFA magic: expected \"RVFA\", got \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/appliance/rvfa-signing.ts","lineNumber":175,"sourceCode":"\n/**\n * Parse an RVFA binary into its components without full validation.\n * Returns the header object, header JSON bytes, section data region, and footer.\n */\nfunction parseRvfaBinary(buf: Buffer): {\n  header: Record<string, unknown>;\n  headerStart: number;\n  headerEnd: number;\n  sectionData: Buffer;\n  footer: Buffer;\n} {\n  if (buf.length < PREAMBLE_SIZE + SHA256_SIZE) {\n    throw new Error('Buffer too small to be a valid RVFA file');\n  }\n\n  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","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/appliance/rvfa-signing.ts#L157-L193","documentation":"Thrown when the first 4 bytes of the buffer are not the ASCII bytes 'RVFA'. The magic is a type tag: a file missing it is simply not an RVFA image, regardless of size.","triggerScenarios":"Passing a JPEG, ELF, ZIP, text file, or any non-RVFA artifact to parseRvfaBinary; passing a base64/hex-encoded RVFA blob without decoding first.","commonSituations":"User pointed the signer at the wrong artifact; file extension mismatch; encoded blob treated as raw bytes.","solutions":["Verify magic bytes: buf.subarray(0,4).toString('ascii') === 'RVFA'.","Decode base64/hex wrappers before parsing.","Point the command at the correct RVFA artifact path."],"exampleFix":"// before\nparseRvfaBinary(Buffer.from(b64String));\n\n// after\nparseRvfaBinary(Buffer.from(b64String, 'base64'));","handlingStrategy":"type-guard","validationCode":"function looksLikeRvfa(buf: Buffer): boolean {\n  return Buffer.isBuffer(buf) && buf.length >= 4 && buf.subarray(0, 4).toString('ascii') === 'RVFA';\n}\nif (!looksLikeRvfa(buf)) throw new Error('Not an RVFA image');","typeGuard":"function isRvfaBuffer(buf: unknown): buf is Buffer {\n  return Buffer.isBuffer(buf) && buf.length >= 4 && buf.subarray(0, 4).toString('ascii') === 'RVFA';\n}","tryCatchPattern":null,"preventionTips":["Sniff magic bytes before committing to a parser.","Keep distinct file formats behind distinct loaders.","Decode base64/hex wrappers before the magic check."],"tags":["rvfa-signing","file-format","validation","magic-bytes"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}