{"record":{"id":"676ae2074e74f63f","repo":"anomalyco/sst","slug":"you-cannot-provide-both-job-and-function-in-th-676ae2","errorCode":null,"errorMessage":"You cannot provide both \"job\" and \"function\" in the \"${name}\" Cron component. The \"job\" property has been deprecated. Use \"function\" instead.","messagePattern":"You cannot provide both \"job\" and \"function\" in the \"(.+?)\" Cron component\\. The \"job\" property has been deprecated\\. Use \"function\" instead\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/cron.ts","lineNumber":261,"sourceCode":"    const parent = this;\n\n    const fnArgs = normalizeFunction();\n    const event = output(args.event || {});\n    normalizeTargets();\n    const enabled = output(args.enabled ?? true);\n    const rule = createRule();\n    const fn = createFunction();\n    const role = createRole();\n    const target = createTarget();\n\n    this.name = name;\n    this.fn = fn;\n    this.rule = rule;\n    this.target = target;\n\n    function normalizeFunction() {\n      if (args.job && args.function)\n        throw new VisibleError(\n          `You cannot provide both \"job\" and \"function\" in the \"${name}\" Cron component. The \"job\" property has been deprecated. Use \"function\" instead.`,\n        );\n\n      const input = args.function ?? args.job;\n      return input ? output(input) : undefined;\n    }\n\n    function normalizeTargets() {\n      if (fnArgs && args.task)\n        throw new VisibleError(\n          `You cannot provide both a function and a task in the \"${name}\" Cron component.`,\n        );\n    }\n\n    function createRule() {\n      return new cloudwatch.EventRule(\n        ...transform(\n          args.transform?.rule,","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/cron.ts#L243-L279","documentation":"SST's Cron component (v1) accepts the scheduled function via `function` or the deprecated `job` property. This VisibleError is thrown in normalizeFunction when both are provided, since the component cannot decide which one to use. The message directs you to the `function` property.","triggerScenarios":"`new sst.aws.Cron(name, {...})` with both `args.function` and `args.job` set — typically after a partial migration from `job` to `function`.","commonSituations":"Upgrading sst.config.ts from the old `job` API and leaving the old key; copy-paste of older examples combined with modern autocomplete; a template with both keys present.","solutions":["Remove the deprecated `job` property and keep `function`","Move any nested configuration from `job` into `function` and delete `job`","Grep the config for `job:` inside Cron args to catch all occurrences"],"exampleFix":"// before\nnew sst.aws.Cron(\"MyCron\", {\n  schedule: \"rate(1 day)\",\n  job: handler,\n  function: handler,\n});\n// after\nnew sst.aws.Cron(\"MyCron\", {\n  schedule: \"rate(1 day)\",\n  function: handler,\n});","handlingStrategy":"validation","validationCode":"function validateCronArgs(args: sst.aws.CronArgs) {\n  if (args.job && args.function)\n    throw new Error(\"Set only one of 'job' (deprecated) or 'function', not both\");\n}","typeGuard":"function hasNoPropConflict(a: Record<string, unknown>, k1: string, k2: string): boolean {\n  return !(a[k1] && a[k2]);\n}","tryCatchPattern":"try {\n  new sst.aws.Cron(\"MyCron\", args);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('both \"job\" and \"function\"')) {\n    console.error(\"Remove the deprecated 'job' property; use 'function' only\");\n  } else throw e;\n}","preventionTips":["Use `function` only; treat `job` as removed in all Cron args","Run `sst dev` after config edits to catch duplicates early","Search for `job:` in sst.config.ts when upgrading SST"],"tags":["config","validation","deprecated-api","cron"],"backgroundTag":"conflicting-component-props","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}