{"record":{"id":"cc4d7c429add8b21","repo":"mastra-ai/mastra","slug":"presets-file-not-found-absolutepath","errorCode":null,"errorMessage":"Presets file not found: ${absolutePath}","messagePattern":"Presets file not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/utils/validate-presets.ts","lineNumber":16,"sourceCode":"import { existsSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\n\n/**\n * Loads and validates a request context presets JSON file.\n *\n * @param presetsPath - Path to the presets JSON file (relative or absolute)\n * @returns The original JSON string content\n * @throws Error if file doesn't exist, JSON is invalid, or structure is incorrect\n */\nexport async function loadAndValidatePresets(presetsPath: string): Promise<string> {\n  const absolutePath = resolve(process.cwd(), presetsPath);\n\n  if (!existsSync(absolutePath)) {\n    throw new Error(`Presets file not found: ${absolutePath}`);\n  }\n\n  const content = await readFile(absolutePath, 'utf-8');\n\n  let parsed: unknown;\n  try {\n    parsed = JSON.parse(content);\n  } catch {\n    throw new Error(`Invalid JSON in presets file: ${presetsPath}`);\n  }\n\n  if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n    throw new Error(`Presets file must contain a JSON object with named presets`);\n  }\n\n  // Validate each preset value is an object\n  for (const [key, value] of Object.entries(parsed)) {\n    if (typeof value !== 'object' || value === null || Array.isArray(value)) {","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/utils/validate-presets.ts#L1-L34","documentation":"loadAndValidatePresets() resolves the given presets path against process.cwd() and throws immediately if the file does not exist on disk. The CLI's dev and studio commands call it when a presets file is supplied, so this error means the path you passed (e.g. via --presets) could not be found. It surfaces the fully resolved absolute path so you can see exactly where the CLI looked.","triggerScenarios":"Calling `mastra dev` or `mastra studio` with a presets file flag/path that does not exist, or running the command from a different working directory so a relative path no longer resolves.","commonSituations":"Typo in the file name or extension (e.g. .jsonc instead of .json), running the CLI from a subdirectory so relative paths break, CI checkout missing a gitignored presets file, or the file was renamed/deleted.","solutions":["Verify the resolved absolute path in the error message exists: ls <absolutePath>.","Run the command from the project root or pass an absolute path to the presets file.","Fix typos in the file name/extension and confirm the file is not gitignored/missing in CI."],"exampleFix":"// before\nmastra dev --presets ./config/presets.json  // file is at ./configs/presets.json\n// after\nmastra dev --presets ./configs/presets.json","handlingStrategy":"validation","validationCode":"import { existsSync, statSync } from 'node:fs';\nimport { resolve } from 'node:path';\nfunction validatePresetsFile(path: string): string | null {\n  const abs = resolve(process.cwd(), path);\n  if (!existsSync(abs)) return `Presets file not found: ${abs}`;\n  if (!statSync(abs).isFile()) return `Not a file: ${abs}`;\n  return null;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await loadAndValidatePresets(presetsPath);\n} catch (err) {\n  if ((err as Error).message.startsWith('Presets file not found')) {\n    console.error(`Check --presets path (resolved against cwd=${process.cwd()}): ${(err as Error).message}`);\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Always pass absolute paths in CI/scripts so cwd changes don't break resolution.","Add the presets file to the repo and assert its existence in setup scripts.","Log process.cwd() alongside the error when paths are relative."],"tags":["cli","filesystem","config","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}