{"record":{"id":"f8f5532581c7be8c","repo":"ruvnet/ruflo","slug":"section-sec-id-extends-beyond-buffer-offset","errorCode":null,"errorMessage":"Section \"${sec.id}\" extends beyond buffer (offset=${sec.offset}, size=${sec.size}, bufLen=${totalSize})","messagePattern":"Section \"(.+?)\" extends beyond buffer \\(offset=(.+?), size=(.+?), bufLen=(.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/appliance/rvfa-format.ts","lineNumber":361,"sourceCode":"    try {\n      parsed = JSON.parse(headerSlice.toString('utf-8'));\n    } catch {\n      throw new Error('Failed to parse RVFA header JSON');\n    }\n\n    if (!validateHeader(parsed)) {\n      throw new Error('RVFA header failed validation');\n    }\n    const header = parsed as RvfaHeader;\n\n    // Bounds-check every section offset\n    const totalSize = buf.length;\n    for (const sec of header.sections) {\n      if (sec.offset < 0 || sec.size < 0) {\n        throw new Error(`Section \"${sec.id}\" has negative offset or size`);\n      }\n      if (sec.offset + sec.size > totalSize - SHA256_SIZE) {\n        throw new Error(\n          `Section \"${sec.id}\" extends beyond buffer ` +\n            `(offset=${sec.offset}, size=${sec.size}, bufLen=${totalSize})`,\n        );\n      }\n    }\n\n    // Check for overlapping sections\n    const sorted = [...header.sections].sort((a, b) => a.offset - b.offset);\n    for (let i = 1; i < sorted.length; i++) {\n      const prev = sorted[i - 1];\n      const curr = sorted[i];\n      if (prev.offset + prev.size > curr.offset) {\n        throw new Error(\n          `Sections \"${prev.id}\" and \"${curr.id}\" overlap ` +\n            `(${prev.offset}+${prev.size} > ${curr.offset})`,\n        );\n      }\n    }","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/appliance/rvfa-format.ts#L343-L379","documentation":"Thrown by RvfaReader.fromBuffer() when a section's declared (offset + size) exceeds the buffer length minus the 32-byte SHA256 footer. The section table points past the end of the available data, meaning either the section data was truncated or the offsets in the header are wrong. The message names the offending section and prints its offset, size, and the buffer length for diagnosis.","triggerScenarios":"The appliance file was truncated after the header but before all section bytes were written; the header offsets are stale relative to a body that was shortened; a custom writer computed offsets against a larger buffer than it actually emitted.","commonSituations":"Interrupted build or download; disk-full during write; a section that was stripped without updating the header; a copy that truncated the file.","solutions":["Rebuild or re-download the appliance; the section data region is incomplete.","Compare the file size to the sum of header offsets+sizes plus preamble+footer.","If you control the writer, verify offset+size <= totalLen - 32 before finalizing.","Inspect the named section's header entry to confirm the offset is plausible."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { validateHeader } from './rvfa-format.js';\nfunction sectionsFitBuffer(buf: Buffer): boolean {\n  const hLen = buf.readUInt32LE(8);\n  const parsed = JSON.parse(buf.subarray(12, 12 + hLen).toString('utf-8'));\n  if (!validateHeader(parsed)) return false;\n  const usable = buf.length - 32; // minus SHA256 footer\n  return (parsed as any).sections.every((s: any) => s.offset + s.size <= usable);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const reader = RvfaReader.fromBuffer(buf);\n} catch (e) {\n  if (/extends beyond buffer/.test((e as Error).message)) {\n    throw new Error('Section data region is truncated; re-download or rebuild the appliance');\n  }\n  throw e;\n}","preventionTips":["Verify the file size matches preamble + sum(section sizes) + 32-byte footer before parsing.","Write appliances atomically (tmp + rename) to avoid truncated files on disk.","Use content-addressed storage (IPFS) so truncation produces a different CID.","Run reader.verify() to catch integrity issues after parsing."],"tags":["rvfa","section","bounds","truncation"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}