{"record":{"id":"9c3ec5697f7b9402","repo":"affaan-m/ECC","slug":"label-is-too-large-opened-size-bytes","errorCode":null,"errorMessage":"${label} is too large (${opened.size} bytes).","messagePattern":"(.+?) is too large \\((.+?) bytes\\)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/memory-vault.js","lineNumber":170,"sourceCode":"  const descriptor = fs.openSync(filePath, flags);\n  try {\n    const opened = fs.fstatSync(descriptor, { bigint: true });\n    if (!opened.isFile()) {\n      throw new Error(`${label} must be a regular, non-symlink file.`);\n    }\n    const after = fs.lstatSync(filePath, { bigint: true });\n    if (\n      after.isSymbolicLink()\n      || !after.isFile()\n      || !sameFileIdentity(after, opened)\n    ) {\n      throw new Error(`${label} must remain a regular, non-symlink file while it is opened.`);\n    }\n    if (options.trustedRoot) {\n      assertWithinTrustedRoot(filePath, options.trustedRoot, `read ${label}`);\n    }\n    if (opened.size > BigInt(maxBytes)) {\n      throw new Error(`${label} is too large (${opened.size} bytes).`);\n    }\n\n    const chunks = [];\n    let total = 0;\n    while (total <= maxBytes) {\n      const buffer = Buffer.alloc(Math.min(64 * 1024, maxBytes + 1 - total));\n      const bytesRead = fs.readSync(descriptor, buffer, 0, buffer.length, null);\n      if (bytesRead === 0) break;\n      chunks.push(buffer.subarray(0, bytesRead));\n      total += bytesRead;\n    }\n    if (total > maxBytes) {\n      throw new Error(`${label} is too large (maximum ${maxBytes} bytes).`);\n    }\n    return decodeUtf8(Buffer.concat(chunks, total), label);\n  } finally {\n    fs.closeSync(descriptor);\n  }","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/memory-vault.js#L152-L188","documentation":"readRegularTextFile throws when the opened file exceeds the configured maxBytes cap (default MAX_DOCUMENT_BYTES). It bounds memory usage when loading vault documents; the faulting input is the oversized file named by `label`.","triggerScenarios":"Thrown at scripts/lib/memory-vault.js:170 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Split or prune the memory document below the size cap.","Pass a larger maxBytes option if the caller legitimately needs bigger documents.","Archive oversized documents instead of loading them whole."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}