ruvnet/ruflo · error · Error

Invalid RVFA magic: expected "RVFA", got "${magic}"

Error message

Invalid RVFA magic: expected "RVFA", got "${magic}"

What it means

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.

Source

Thrown at v3/@claude-flow/cli/src/appliance/rvfa-signing.ts:175

/**
 * Parse an RVFA binary into its components without full validation.
 * Returns the header object, header JSON bytes, section data region, and footer.
 */
function parseRvfaBinary(buf: Buffer): {
  header: Record<string, unknown>;
  headerStart: number;
  headerEnd: number;
  sectionData: Buffer;
  footer: Buffer;
} {
  if (buf.length < PREAMBLE_SIZE + SHA256_SIZE) {
    throw new Error('Buffer too small to be a valid RVFA file');
  }

  const magic = buf.subarray(0, 4).toString('ascii');
  if (magic !== 'RVFA') {
    throw new Error(`Invalid RVFA magic: expected "RVFA", got "${magic}"`);
  }

  const headerLen = buf.readUInt32LE(8);
  const headerStart = PREAMBLE_SIZE;
  const headerEnd = headerStart + headerLen;

  if (headerEnd > buf.length - SHA256_SIZE) {
    throw new Error('Header length extends beyond buffer');
  }

  const headerJson = buf.subarray(headerStart, headerEnd).toString('utf-8');
  let header: Record<string, unknown>;
  try {
    header = JSON.parse(headerJson) as Record<string, unknown>;
  } catch {
    throw new Error('Failed to parse RVFA header JSON');
  }

View on GitHub (pinned to 6b01dc5a68)

Solutions

  1. Verify magic bytes: buf.subarray(0,4).toString('ascii') === 'RVFA'.
  2. Decode base64/hex wrappers before parsing.
  3. Point the command at the correct RVFA artifact path.

Example fix

// before
parseRvfaBinary(Buffer.from(b64String));

// after
parseRvfaBinary(Buffer.from(b64String, 'base64'));
Defensive patterns

Strategy: type-guard

Validate before calling

function looksLikeRvfa(buf: Buffer): boolean {
  return Buffer.isBuffer(buf) && buf.length >= 4 && buf.subarray(0, 4).toString('ascii') === 'RVFA';
}
if (!looksLikeRvfa(buf)) throw new Error('Not an RVFA image');

Type guard

function isRvfaBuffer(buf: unknown): buf is Buffer {
  return Buffer.isBuffer(buf) && buf.length >= 4 && buf.subarray(0, 4).toString('ascii') === 'RVFA';
}

Prevention

When it happens

Trigger: Passing a JPEG, ELF, ZIP, text file, or any non-RVFA artifact to parseRvfaBinary; passing a base64/hex-encoded RVFA blob without decoding first.

Common situations: User pointed the signer at the wrong artifact; file extension mismatch; encoded blob treated as raw bytes.

Related errors


AI-assisted analysis of ruvnet/ruflo@6b01dc5a68 (2026-08-12). Data as JSON: /api/errors/c8a03f032945d50d. Report an issue: GitHub.