{"record":{"id":"68ca2ed5c9ff2184","repo":"payloadcms/payload","slug":"task-taskslug-not-found-in-workflow-job-workf","errorCode":null,"errorMessage":"Task ${taskSlug} not found in workflow ${job.workflowSlug}","messagePattern":"Task (.+?) not found in workflow (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/payload/src/queues/operations/runJobs/runJob/getRunTaskFunction.ts","lineNumber":66,"sourceCode":"  ) =>\n    (async (\n      taskID: Parameters<RunInlineTaskFunction>[0],\n      {\n        input,\n        retries,\n        // Only available for inline tasks:\n        task,\n      }: Parameters<RunInlineTaskFunction>[1] & Parameters<RunTaskFunction<string>>[1],\n    ) => {\n      const executedAt = getCurrentDate()\n\n      let taskConfig: TaskConfig | undefined\n      if (!isInline) {\n        taskConfig = (jobConfig.tasks?.length &&\n          jobConfig.tasks.find((t) => t.slug === taskSlug)) as TaskConfig<string>\n\n        if (!taskConfig) {\n          throw new Error(`Task ${taskSlug} not found in workflow ${job.workflowSlug}`)\n        }\n      }\n\n      const retriesConfigFromPropsNormalized =\n        retries == undefined || retries == null\n          ? {}\n          : typeof retries === 'number'\n            ? { attempts: retries }\n            : retries\n      const retriesConfigFromTaskConfigNormalized = taskConfig\n        ? typeof taskConfig.retries === 'number'\n          ? { attempts: taskConfig.retries }\n          : taskConfig.retries\n        : {}\n\n      const finalRetriesConfig: RetryConfig = {\n        ...retriesConfigFromTaskConfigNormalized,\n        ...retriesConfigFromPropsNormalized, // Retry config from props takes precedence","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/queues/operations/runJobs/runJob/getRunTaskFunction.ts#L48-L84","documentation":"Thrown inside `getRunTaskFunction` when a non-inline task slug referenced by the job does not exist in the workflow's `jobConfig.tasks` list. The runner looks up the task config by slug to find its handler and retries config; a miss means the job's stored task reference is out of sync with the deployed workflow config.","triggerScenarios":"A queued job references a task slug that was renamed or removed from the workflow after the job was enqueued; running old job data against a newer workflow config; a typo in the task slug used in a workflow's `tasks` wiring.","commonSituations":"Deploying a workflow change (rename/remove task) while jobs referencing the old task are still in the queue; branching config divergence; manually inserted job rows with wrong task slugs.","solutions":["Ensure the workflow's `tasks` array defines a task with the exact slug the job references.","Drain or migrate queued jobs before deploying a workflow that renames/removes a task.","Inspect the failing job document's `workflowSlug`/task reference and reconcile with current config."],"exampleFix":"// before\nworkflows: [{\n  slug: 'import',\n  tasks: [{ slug: 'parse' /* but job references 'parse-csv' */ }],\n}]\n\n// after\nworkflows: [{\n  slug: 'import',\n  tasks: [{ slug: 'parse-csv', handler: async () => {} }],\n}]","handlingStrategy":"try-catch","validationCode":"import type { Config } from 'payload'\n\nfunction assertWorkflowTaskExists(cfg: Config, workflowSlug: string, taskSlug: string): void {\n  const wf = cfg.jobs?.workflows?.find((w) => w.slug === workflowSlug)\n  const exists = wf?.tasks?.some((t) => t.slug === taskSlug)\n  if (!exists) {\n    throw new Error(`Task ${taskSlug} not defined in workflow ${workflowSlug}`)\n  }\n}","typeGuard":"function workflowDefinesTask(\n  workflows: { slug: string; tasks?: { slug: string }[] }[],\n  workflowSlug: string,\n  taskSlug: string,\n): boolean {\n  return workflows\n    .find((w) => w.slug === workflowSlug)\n    ?.tasks?.some((t) => t.slug === taskSlug) ?? false\n}","tryCatchPattern":"try {\n  await runJobs({ req })\n} catch (err) {\n  if (err instanceof Error && err.message.includes('not found in workflow')) {\n    // reconcile job data with current workflow config; drain stale jobs\n  } else throw err\n}","preventionTips":["Drain the jobs queue before deploying a workflow that renames/removes a task.","Add a config test asserting every queued job's task slug exists in current config.","Version workflows (e.g. slug suffix) when making breaking task changes."],"tags":["jobs","workflows","tasks","configuration"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}