{"record":{"id":"3250e553f0a2a170","repo":"mastra-ai/mastra","slug":"enoent","errorCode":"ENOENT","errorMessage":"File not found: ${path}","messagePattern":"File not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"packages/core/src/workspace/filesystem/fs-utils.ts","lineNumber":338,"sourceCode":" * @param absolutePath - The absolute path to stat\n * @param userPath - The user-facing path for error messages\n * @returns File stat information\n * @throws {FileNotFoundError} if path doesn't exist\n */\nexport async function fsStat(absolutePath: string, userPath: string): Promise<FsStatResult> {\n  try {\n    const stats = await fs.stat(absolutePath);\n    return {\n      name: path.basename(absolutePath),\n      type: stats.isDirectory() ? 'directory' : 'file',\n      size: stats.size,\n      createdAt: stats.birthtime,\n      modifiedAt: stats.mtime,\n      mimeType: stats.isFile() ? getMimeType(absolutePath) : undefined,\n    };\n  } catch (error: unknown) {\n    if (isEnoentError(error)) {\n      throw new FileNotFoundError(userPath);\n    }\n    throw error;\n  }\n}\n","sourceCodeStart":320,"sourceCodeEnd":343,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workspace/filesystem/fs-utils.ts#L320-L343","documentation":"fsStat in fs-utils wraps a low-level stat call; when the underlying filesystem reports ENOENT it rethrows it as FileNotFoundError with message \"File not found: <path>\". The library normalizes platform-specific ENOENT errors into a single predictable error type for callers.","triggerScenarios":"Calling stat()/stats()/result() on a path that does not exist on disk: file deleted between listing and stat, wrong basePath configured, case-sensitivity mismatch on Linux, symlink to a missing target.","commonSituations":"Race conditions where a temp file was cleaned up before stat; relative path resolved against the wrong workspace base; typos in filenames; CI environments where fixtures were never written.","solutions":["Check fs.existsSync()/await fs.exists(path) before stat, or handle FileNotFoundError.","Verify the configured basePath and that the path is correctly joined/normalized.","If the file should exist, re-run the producing step; if deletion is expected, treat this as a normal miss."],"exampleFix":"// before\nconst s = await fsStat(workspace, './build/out.json');\n// after\nif (await workspaceExists(workspace, './build/out.json')) {\n  const s = await fsStat(workspace, './build/out.json');\n} else {\n  throw new Error('Build output missing; run the build first');\n}","handlingStrategy":"try-catch","validationCode":"if (!(await fsExists(path))) return null; // skip stat for known-missing files","typeGuard":null,"tryCatchPattern":"try {\n  return await fsStat(path);\n} catch (e) {\n  if (e instanceof Error && /File not found/i.test(e.message)) {\n    return null; // treat as missing file\n  }\n  throw e;\n}","preventionTips":["Check existence before stat when files may be transient.","Verify basePath configuration; most 'missing' files are resolved against the wrong root.","Account for case sensitivity when moving code between macOS and Linux."],"tags":["filesystem","enoent","file-not-found"],"backgroundTag":"file-not-found-enoent","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}