{"record":{"id":"75c1ae63d03a5b3b","repo":"nexu-io/open-design","slug":"project-files-read-json-file-exceeds-256kb","errorCode":null,"errorMessage":"project_files.read_json file exceeds 256KB","messagePattern":"project_files\\.read_json file exceeds 256KB","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/daemon/src/live-artifacts/refresh.ts","lineNumber":599,"sourceCode":"  }\n\n  return asBoundedRefreshOutput({ toolName: 'project_files.search', query: query ?? '', count: matches.length, truncated: allFiles.length > matches.length && matches.length >= maxResults, matches });\n}\n\nasync function executeProjectFilesReadJson(options: ExecuteLocalDaemonRefreshSourceOptions): Promise<BoundedJsonObject> {\n  const filePath = selectJsonPath(options.source.input as ProjectFilesReadJsonInput);\n  if (!filePath.endsWith('.json')) throw new Error('project_files.read_json only supports .json files');\n  const dir = projectDir(options.projectsRoot, options.projectId);\n  const target = path.resolve(dir, filePath);\n  const [dirReal, targetLinkStat] = await Promise.all([realpath(dir), lstat(target)]);\n  if (targetLinkStat.isSymbolicLink()) throw new Error('project_files.read_json does not follow symlinks');\n  const targetReal = await realpath(target);\n  if (!targetReal.startsWith(`${dirReal}${path.sep}`) && targetReal !== dirReal) {\n    throw new Error('project_files.read_json path escapes project dir');\n  }\n  const entryStat = await stat(targetReal);\n  if (!entryStat.isFile()) throw new Error('project_files.read_json path must be a file');\n  if (entryStat.size > 256 * 1024) throw new Error('project_files.read_json file exceeds 256KB');\n  if (options.signal?.aborted === true) throw options.signal.reason;\n  let parsed: BoundedJsonValue;\n  try {\n    parsed = JSON.parse(await readFile(targetReal, 'utf8')) as BoundedJsonValue;\n  } catch {\n    throw new Error(`project_files.read_json could not parse JSON at ${filePath}`);\n  }\n  return asBoundedRefreshOutput({ toolName: 'project_files.read_json', path: filePath, size: entryStat.size, json: parsed });\n}\n\nfunction compactExecOutput(value: string): string[] {\n  return value.split('\\n').map((line) => line.trimEnd()).filter(Boolean).slice(0, 100);\n}\n\nasync function runGit(projectPath: string, args: string[], signal: AbortSignal | undefined): Promise<string> {\n  try {\n    const result = await execFileAsync('git', args, { cwd: projectPath, signal, timeout: 10_000, maxBuffer: 128 * 1024 });\n    return result.stdout.toString();","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/live-artifacts/refresh.ts#L581-L617","documentation":"executeProjectFilesReadJson (refresh.ts:598-599) rejects files whose stat size exceeds 256 * 1024 bytes (256 KiB). This cap keeps the parsed JSON within bounded-JSON limits and avoids loading oversized files into the refresh pipeline.","triggerScenarios":"input.path points to a .json file larger than 256 KiB (262144 bytes).","commonSituations":"Large data exports, bundled manifests, lockfile-sized JSON, or untrimmed datasets committed to the project.","solutions":["Slim the JSON file below 256 KiB by removing unused keys or splitting it.","Point read_json at a smaller, pre-summarized slice of the data.","Use outputMapping.dataPaths so only needed fields are retained (note: the file itself must still be under 256 KiB to be read at all)."],"exampleFix":"// before: metrics.json is 1.2 MB\nconst input = { path: 'metrics.json' };\n// throws `project_files.read_json file exceeds 256KB`\n\n// after: extract the needed subset into a smaller file\nconst input = { path: 'metrics-summary.json' }; // < 256 KiB","handlingStrategy":"validation","validationCode":"import { stat } from 'node:fs/promises';\nconst MAX = 256 * 1024;\nasync function assertUnderSizeLimit(target: string): Promise<void> {\n  const st = await stat(target);\n  if (st.size > MAX) throw new Error('project_files.read_json file exceeds 256KB');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep JSON data files small; split large datasets into per-record or summarized files.","Check file size in the path picker UI and disable files over 256 KiB for read_json.","Pre-summarize data so the refresh source reads a compact file."],"tags":["live-artifacts","project-files","size-limit"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}