{"record":{"id":"9f145c43c629ace7","repo":"anomalyco/sst","slug":"no-function-created-for-the-self-name-cron-jo","errorCode":null,"errorMessage":"No function created for the \"${self.name}\" cron job.","messagePattern":"No function created for the \"(.+?)\" cron job\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/cron.ts","lineNumber":406,"sourceCode":"          { parent },\n        ),\n      );\n    }\n  }\n\n  /**\n   * The underlying [resources](/docs/components/#nodes) this component creates.\n   */\n  public get nodes() {\n    const self = this;\n    return {\n      /**\n       * The AWS Lambda Function that'll be invoked when the cron job runs.\n       * @deprecated Use `nodes.function` instead.\n       */\n      get job() {\n        if (!self.fn)\n          throw new VisibleError(\n            `No function created for the \"${self.name}\" cron job.`,\n          );\n        return self.fn.apply((fn) => fn.getFunction());\n      },\n      /**\n       * The AWS Lambda Function that'll be invoked when the cron job runs.\n       */\n      get function() {\n        if (!self.fn)\n          throw new VisibleError(\n            `No function created for the \"${self.name}\" cron job.`,\n          );\n        return self.fn.apply((fn) => fn.getFunction());\n      },\n      /**\n       * The EventBridge Rule resource.\n       */\n      rule: this.rule,","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/cron.ts#L388-L424","documentation":"The deprecated `cron.nodes.job` getter returns the Lambda Function node and throws this VisibleError when the Cron was not created with a function (e.g. it was created with an ECS `task` or no target), since `self.fn` is undefined.","triggerScenarios":"Accessing `cron.nodes.job` on a Cron instance created with `task` or without a function target.","commonSituations":"Legacy code referencing the deprecated `nodes.job` accessor; shared helper functions that assume every cron has a Lambda function and try to add permissions or triggers.","solutions":["Use `nodes.function` instead of the deprecated `nodes.job`","Check that the cron was created with a `function` before accessing the node","For task-based crons, use the task's resources instead"],"exampleFix":"// before\nconst fn = cron.nodes.job;\n// after\nconst fn = cron.nodes.function; // when the cron has a function target","handlingStrategy":"type-guard","validationCode":"const fn = cronArgs.function ? cron.nodes.job : undefined;","typeGuard":"function hasFunctionNode(cron: sst.aws.Cron, args: sst.aws.CronArgs): boolean {\n  return Boolean(args.function || args.job);\n}","tryCatchPattern":"let fn;\ntry {\n  fn = cron.nodes.job;\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"No function created\")) {\n    fn = undefined; // task-based cron\n  } else throw e;\n}","preventionTips":["Migrate to `nodes.function`; `nodes.job` is deprecated","Do not assume every cron has a Lambda function","Gate node access on the cron's construction args"],"tags":["deprecated-api","accessor","cron","lambda"],"backgroundTag":"deprecated-node-accessor","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}