ruvnet/ruflo · error · Error
Header length extends beyond buffer
Error message
Header length extends beyond buffer
What it means
Thrown when headerStart + headerLen (the 4-byte length read from the preamble at offset 8) would read past the buffer minus the footer. The preamble's length field is inconsistent with the file size — a corrupt or truncated image.
Source
Thrown at v3/@claude-flow/cli/src/appliance/rvfa-signing.ts:183
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');
}
const footer = buf.subarray(buf.length - SHA256_SIZE);
const sectionData = buf.subarray(headerEnd, buf.length - SHA256_SIZE);
return { header, headerStart, headerEnd, sectionData, footer };
}
/**
* Compute the signing digest for an RVFA file.View on GitHub (pinned to 6b01dc5a68)
Solutions
- Re-acquire the RVFA file from a trusted source.
- On the producer side, cross-check the declared header length against actual bytes written.
- Treat the image as unrecoverable; do not retry on the same bytes.
Defensive patterns
Strategy: validation
Validate before calling
const headerLen = buf.readUInt32LE(8);
if (PREAMBLE_SIZE + headerLen > buf.length - SHA256_SIZE) {
throw new Error('RVFA header length inconsistent with file size; image is corrupt or truncated');
} Prevention
- Validate framing lengths before trusting preamble fields.
- Do not retry parse on the same corrupt bytes.
- On the writer, assert headerLen matches bytes written.
When it happens
Trigger: The declared header length exceeds the available bytes between preamble and footer: truncated file, partial overwrite, or a bit-flip in the length field.
Common situations: Partial download; file truncated by a size-limited transfer; producer wrote a wrong length field.
Related errors
- Failed to parse RVFA header JSON
- RVFP header magic mismatch
- Section "${id}" exceeds buffer bounds
- Buffer too small to be a valid RVFA file
- KV cache file too small
AI-assisted analysis of ruvnet/ruflo@6b01dc5a68 (2026-08-12).
Data as JSON: /api/errors/a2f4fd591f7521f6.
Report an issue: GitHub.