{"record":{"id":"47dd913ce1c99619","repo":"ruvnet/ruflo","slug":"buffer-too-small-to-be-a-valid-rvfa-file","errorCode":null,"errorMessage":"Buffer too small to be a valid RVFA file","messagePattern":"Buffer too small to be a valid RVFA file","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/appliance/rvfa-signing.ts","lineNumber":170,"sourceCode":"      return sorted;\n    }\n    return val;\n  });\n}\n\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 {","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/appliance/rvfa-signing.ts#L152-L188","documentation":"Thrown by parseRvfaBinary when the input is smaller than the minimum RVFA framing (preamble + SHA256 footer). A buffer this short cannot structurally be an RVFA image.","triggerScenarios":"Passing an empty buffer, a few-byte stub, or a non-RVFA file (text, directory read as bytes) to the signing parser.","commonSituations":"Wrong file path resolving to a tiny artifact; a download that produced 0 bytes; reading a symlink target that is empty.","solutions":["Confirm the input is actually an RVFA image.","Stat the file and reject obviously small files before reading.","Re-fetch the file if its size is implausibly small."],"exampleFix":"// before\nparseRvfaBinary(await readFile(maybeBrokenPath));\n\n// after\nconst buf = await readFile(maybeBrokenPath);\nif (buf.length < PREAMBLE_SIZE + SHA256_SIZE) {\n  throw new Error(`File too small (${buf.length} bytes) to be RVFA`);\n}\nparseRvfaBinary(buf);","handlingStrategy":"validation","validationCode":"const MIN_RVFA = PREAMBLE_SIZE + SHA256_SIZE; // e.g. 12 + 32\nif (!Buffer.isBuffer(buf) || buf.length < MIN_RVFA) {\n  throw new Error(`Not an RVFA file (only ${buf?.length ?? 0} bytes)`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Stat the file and reject obviously small files before reading.","Keep framing constants exported so callers can pre-check.","Distinguish 'too small' from 'wrong magic' for clearer diagnostics."],"tags":["rvfa-signing","buffer-bounds","validation","file-format"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}