{"record":{"id":"b95efb46c2d8d278","repo":"nexu-io/open-design","slug":"project-files-read-json-path-must-be-a-file","errorCode":null,"errorMessage":"project_files.read_json path must be a file","messagePattern":"project_files\\.read_json path must be a file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/daemon/src/live-artifacts/refresh.ts","lineNumber":598,"sourceCode":"    matches.push(result);\n  }\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 });","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/live-artifacts/refresh.ts#L580-L616","documentation":"executeProjectFilesReadJson (refresh.ts:597-598) stats the resolved real target and requires it to be a regular file (entryStat.isFile()). A directory, device, socket, or other non-file entry is rejected because the tool can only JSON.parse file contents.","triggerScenarios":"input.path resolves to a directory, a FIFO/socket, or a device special file inside the project.","commonSituations":"Pointing read_json at a directory path (e.g. 'src' instead of 'src/data.json'); a path with a trailing slash; an empty extension that resolved to a folder.","solutions":["Point input.path at a specific .json file, not a directory.","Remove any trailing slash from the path.","Verify the path is a file before scheduling a refresh."],"exampleFix":"// before\nconst input = { path: 'src/' };\n// throws `project_files.read_json path must be a file`\n\n// after\nconst input = { path: 'src/data.json' };","handlingStrategy":"validation","validationCode":"import { stat } from 'node:fs/promises';\nasync function assertIsFile(target: string): Promise<void> {\n  const st = await stat(target);\n  if (!st.isFile()) throw new Error('project_files.read_json path must be a file');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Point read_json at a specific file, never a directory.","Strip trailing slashes from input.path.","Validate the path resolves to a regular file before scheduling refresh."],"tags":["live-artifacts","project-files","filesystem"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}