{"record":{"id":"550f04329d321f77","repo":"serverless/serverless","slug":"file-not-found","errorCode":"FILE_NOT_FOUND","errorMessage":"The file you provided does not exist.","messagePattern":"The file you provided does not exist\\.","errorType":"exception","errorClass":"ServerlessError","httpStatus":null,"severity":"error","filePath":"packages/serverless/lib/plugins/aws/invoke-agent.js","lineNumber":119,"sourceCode":"      } catch {\n        // Keep as string if not valid JSON\n      }\n    }\n  }\n\n  /**\n   * Validate file exists and return contents\n   */\n  async validateFile(key) {\n    const absolutePath = path.resolve(\n      this.serverless.serviceDir,\n      this.options[key],\n    )\n    try {\n      return await this.serverless.utils.readFile(absolutePath)\n    } catch (err) {\n      if (err.code === 'ENOENT') {\n        throw new ServerlessError(\n          'The file you provided does not exist.',\n          'FILE_NOT_FOUND',\n        )\n      }\n      throw err\n    }\n  }\n\n  /**\n   * Get ai configuration\n   */\n  getAiConfig() {\n    const service = this.serverless.service\n\n    if (service.ai) {\n      return service.ai\n    }\n","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/serverless/serverless/blob/b9d7ea51c8cce57cff1207964b9b71123673081f/packages/serverless/lib/plugins/aws/invoke-agent.js#L101-L137","documentation":"Thrown by the invoke-agent plugin when the --path file (agent input payload) cannot be read because it does not exist: serverless.utils.readFile rejects with ENOENT. The path is resolved relative to the service directory.","triggerScenarios":"Running `sls invoke --agent X --path missing.json` where the file is absent.","commonSituations":"Wrong relative path; file located outside the service dir; typo in the filename; file deleted between commands.","solutions":["Confirm the path is relative to the service root (where serverless.yml lives).","Use an absolute path to remove ambiguity.","Create the file if it is genuinely missing."],"exampleFix":"# before\nsls invoke --agent myAgent --path ./dta/input.json\n# after\nsls invoke --agent myAgent --path ./data/input.json","handlingStrategy":"validation","validationCode":"import { pathExists } from 'fs-extra'\nimport path from 'path'\nasync function ensureInputFile(serviceDir, rel) {\n  const abs = path.resolve(serviceDir, rel)\n  if (!(await pathExists(abs))) throw new Error(`--path file not found: ${abs}`)\n  return abs\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve --path against the service directory, not cwd.","Commit agent input fixtures alongside the config so paths stay stable."],"tags":["invoke","agent","file","filesystem"],"backgroundTag":null,"analyzedSha":"b9d7ea51c8cce57cff1207964b9b71123673081f","analyzedAt":"2026-08-13T04:14:40.386Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}