{"record":{"id":"8efae4d693986fde","repo":"anomalyco/sst","slug":"no-function-created-for-the-self-name-cron-j","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-v2.ts","lineNumber":526,"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 Scheduler Schedule resource.\n       */\n      schedule: this._schedule,","sourceCodeStart":508,"sourceCodeEnd":544,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/cron-v2.ts#L508-L544","documentation":"The deprecated `cron.nodes.job` getter returns the Lambda Function node, but it is only available when the cron was actually created with a function target. When the CronV2 was created with a `task` (or no function), accessing `job` throws this VisibleError instead of returning undefined.","triggerScenarios":"Accessing `cron.nodes.job` on a CronV2 instance created with `task` or with no function target at all.","commonSituations":"Legacy code still referencing the deprecated `nodes.job` accessor after switching the cron to an ECS task; generic code that iterates crons and assumes every cron has a function.","solutions":["Use `nodes.function` instead of the deprecated `nodes.job`","Guard by checking that the cron was created with a `function` before accessing the node","If the cron is task-based, access the task resources instead of the function node"],"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.CronV2, args: sst.aws.CronV2Args): 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":["Prefer `nodes.function` over the deprecated `nodes.job`","Remember task-based crons have no function node","Branch on how the cron was constructed before accessing nodes"],"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"}