{"record":{"id":"0a7e251cdbd96241","repo":"ruvnet/ruflo","slug":"buffer-too-small-to-contain-rvfa-preamble","errorCode":null,"errorMessage":"Buffer too small to contain RVFA preamble","messagePattern":"Buffer too small to contain RVFA preamble","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/appliance/rvfa-format.ts","lineNumber":312,"sourceCode":"  }\n}\n\n// ---------------------------------------------------------------------------\n// RvfaReader\n// ---------------------------------------------------------------------------\nexport class RvfaReader {\n  private buf: Buffer;\n  private header: RvfaHeader;\n\n  private constructor(buf: Buffer, header: RvfaHeader) {\n    this.buf = buf;\n    this.header = header;\n  }\n\n  /** Parse an RVFA image from an in-memory Buffer. */\n  static fromBuffer(buf: Buffer): RvfaReader {\n    if (buf.length < PREAMBLE_SIZE) {\n      throw new Error('Buffer too small to contain RVFA preamble');\n    }\n\n    // Magic\n    const magic = buf.subarray(0, MAGIC_SIZE).toString('ascii');\n    if (magic !== 'RVFA') {\n      throw new Error(`Invalid RVFA magic: expected \"RVFA\", got \"${magic}\"`);\n    }\n\n    // Version\n    const version = buf.readUInt32LE(MAGIC_SIZE);\n    if (version !== RVFA_VERSION) {\n      throw new Error(\n        `Unsupported RVFA version: ${version} (expected ${RVFA_VERSION})`,\n      );\n    }\n\n    // Header length\n    const headerLen = buf.readUInt32LE(MAGIC_SIZE + VERSION_SIZE);","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/appliance/rvfa-format.ts#L294-L330","documentation":"Thrown by RvfaReader.fromBuffer() when the buffer is shorter than PREAMBLE_SIZE (12 bytes: 4 magic + 4 version + 4 header-length). It is the first structural gate before any field is read, so it precedes the magic/version checks. Both fromBuffer and fromFile (which delegates to it) can surface this.","triggerScenarios":"Passing an empty or near-empty Buffer to RvfaReader.fromBuffer(), or pointing fromFile() at an empty/truncated .rvfa file. Also: reading a non-appliance file (e.g. a patch, a log) whose size happens to be under 12 bytes.","commonSituations":"A zero-byte .rvfa left by a killed build; an interrupted download; stat()-ing the wrong path; passing a Buffer that was allocated but never populated.","solutions":["Check the file/buffer size is well above 12 bytes before parsing.","Re-run the RVFA build (RvfaBuilder.build()) if the file is empty or truncated.","Re-download the appliance from IPFS if the fetch was interrupted.","Confirm the path points to an .rvfa appliance, not a .rvfp patch."],"exampleFix":"// before\nconst reader = await RvfaReader.fromFile(path); // path may be empty\n\n// after\nconst stat = await fs.stat(path);\nif (stat.size < 12) throw new Error(`${path} is too small to be an RVFA image`);\nconst reader = await RvfaReader.fromFile(path);","handlingStrategy":"validation","validationCode":"const RVFA_PREAMBLE = 12;\nfunction isRvfaSized(buf: Buffer): boolean {\n  return Buffer.isBuffer(buf) && buf.length >= RVFA_PREAMBLE;\n}","typeGuard":"function isRvfaCandidate(buf: unknown): buf is Buffer {\n  return Buffer.isBuffer(buf) && buf.length >= 12;\n}","tryCatchPattern":"try {\n  const reader = RvfaReader.fromBuffer(buf);\n} catch (e) {\n  if (/Buffer too small to contain RVFA preamble/.test((e as Error).message)) {\n    throw new Error(`Buffer is ${buf.length} bytes; an RVFA image must be >= 12 bytes`);\n  }\n  throw e;\n}","preventionTips":["stat() appliance files and reject those under 12 bytes before parsing.","Verify downloads completed against the content-length or reported size.","Keep .rvfa appliance and .rvfp patch files in separate directories.","Rebuild appliances with RvfaBuilder.build() if the file is empty or partial."],"tags":["rvfa","buffer","validation","binary-format"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}