ruvnet/ruflo · error · Error

Sections "${prev.id}" and "${curr.id}" overlap (${prev.offse

Error message

Sections "${prev.id}" and "${curr.id}" overlap (${prev.offset}+${prev.size} > ${curr.offset})

What it means

Thrown by RvfaReader.fromBuffer() during the overlap check: after sorting sections by offset, two adjacent sections' byte ranges intersect (prev.offset + prev.size > curr.offset). The format requires non-overlapping, contiguous-ish sections, so an overlap indicates corrupt offsets or a tampered header. The message names both sections and shows the arithmetic.

Source

Thrown at v3/@claude-flow/cli/src/appliance/rvfa-format.ts:374

    for (const sec of header.sections) {
      if (sec.offset < 0 || sec.size < 0) {
        throw new Error(`Section "${sec.id}" has negative offset or size`);
      }
      if (sec.offset + sec.size > totalSize - SHA256_SIZE) {
        throw new Error(
          `Section "${sec.id}" extends beyond buffer ` +
            `(offset=${sec.offset}, size=${sec.size}, bufLen=${totalSize})`,
        );
      }
    }

    // Check for overlapping sections
    const sorted = [...header.sections].sort((a, b) => a.offset - b.offset);
    for (let i = 1; i < sorted.length; i++) {
      const prev = sorted[i - 1];
      const curr = sorted[i];
      if (prev.offset + prev.size > curr.offset) {
        throw new Error(
          `Sections "${prev.id}" and "${curr.id}" overlap ` +
            `(${prev.offset}+${prev.size} > ${curr.offset})`,
        );
      }
    }

    return new RvfaReader(buf, header);
  }

  /** Read an RVFA image from a file path. */
  static async fromFile(path: string): Promise<RvfaReader> {
    if (path.includes('\0')) {
      throw new Error('Path contains null bytes');
    }
    const data = await readFile(path);
    return RvfaReader.fromBuffer(data);
  }

View on GitHub (pinned to 6b01dc5a68)

Solutions

  1. Regenerate the appliance with RvfaWriter.build() which computes non-overlapping offsets iteratively.
  2. Inspect the section table to confirm offsets are strictly increasing and non-overlapping.
  3. Discard hand-edited or third-party appliances whose offsets were not validated.
  4. If debugging a writer, ensure each section's offset = previous offset + previous size.
Defensive patterns

Strategy: validation

Validate before calling

import { validateHeader } from './rvfa-format.js';
function sectionsDoNotOverlap(buf: Buffer): boolean {
  const hLen = buf.readUInt32LE(8);
  const parsed = JSON.parse(buf.subarray(12, 12 + hLen).toString('utf-8'));
  if (!validateHeader(parsed)) return false;
  const sorted = [...(parsed as any).sections].sort((a: any, b: any) => a.offset - b.offset);
  for (let i = 1; i < sorted.length; i++) {
    if (sorted[i - 1].offset + sorted[i - 1].size > sorted[i].offset) return false;
  }
  return true;
}

Try / catch

try {
  const reader = RvfaReader.fromBuffer(buf);
} catch (e) {
  if (/overlap/.test((e as Error).message)) {
    throw new Error('Section offsets overlap; the header is corrupt or was produced by a buggy writer');
  }
  throw e;
}

Prevention

When it happens

Trigger: Two sections in the header whose [offset, offset+size) ranges overlap. Caused by corrupted offset/size fields, a writer bug that double-assigned an offset, or a hand-edited header.

Common situations: A buggy custom writer that did not advance the cursor between sections; bit-rot that shifted an offset; a header spliced from two different appliances; adversarial input designed to confuse extraction.

Related errors


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