{"record":{"id":"a44fbb0cf852c93e","repo":"payloadcms/payload","slug":"task-slug-task-slug-is-already-used-by-a-work","errorCode":null,"errorMessage":"Task slug \"${task.slug}\" is already used by a workflow. No tasks are allowed to have the same slug as a workflow.","messagePattern":"Task slug \"(.+?)\" is already used by a workflow\\. No tasks are allowed to have the same slug as a workflow\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/payload/src/queues/config/collection.ts","lineNumber":27,"sourceCode":"\nexport const jobsCollectionSlug = 'payload-jobs'\n\nexport const getDefaultJobsCollection: (jobsConfig: SanitizedConfig['jobs']) => CollectionConfig = (\n  jobsConfig,\n) => {\n  const workflowSlugs: Set<string> = new Set()\n  const taskSlugs: Set<string> = new Set(['inline'])\n\n  if (jobsConfig.workflows?.length) {\n    jobsConfig.workflows.forEach((workflow) => {\n      workflowSlugs.add(workflow.slug)\n    })\n  }\n\n  if (jobsConfig.tasks?.length) {\n    jobsConfig.tasks.forEach((task) => {\n      if (workflowSlugs.has(task.slug)) {\n        throw new Error(\n          `Task slug \"${task.slug}\" is already used by a workflow. No tasks are allowed to have the same slug as a workflow.`,\n        )\n      }\n\n      taskSlugs.add(task.slug)\n    })\n  }\n\n  const logFields: Field[] = [\n    {\n      name: 'executedAt',\n      type: 'date',\n      required: true,\n    },\n    {\n      name: 'completedAt',\n      type: 'date',\n      required: true,","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/queues/config/collection.ts#L9-L45","documentation":"Thrown while building the jobs queue config collection when a task's slug collides with an existing workflow slug. Payload disallows the collision because task and workflow slugs share the same namespace on the jobs collection (taskSlugs seeds with 'inline'), so a duplicate would make job routing ambiguous.","triggerScenarios":"Defining `jobs.tasks` and `jobs.workflows` in buildConfig where a task and a workflow share the same `slug`. The error fires at config build time, before the server starts.","commonSituations":"Refactoring a workflow into a standalone task and forgetting to rename; copy-paste of a workflow config into tasks; renaming a workflow but leaving an old task with the same name.","solutions":["Rename the task slug so it is unique across both tasks and workflows.","Audit `payload.config.ts` jobs.workflows and jobs.tasks for duplicate slugs before starting the server.","Add a unit test that builds the config and asserts no slug overlap."],"exampleFix":"// before\njobs: {\n  workflows: [{ slug: 'sync', tasks: [] }],\n  tasks: [{ slug: 'sync', handler: async () => {} }],\n}\n\n// after\njobs: {\n  workflows: [{ slug: 'sync', tasks: [] }],\n  tasks: [{ slug: 'sync-task', handler: async () => {} }],\n}","handlingStrategy":"validation","validationCode":"import config from './payload.config'\n\nfunction assertNoSlugCollision(cfg): void {\n  const workflows = new Set((cfg.jobs?.workflows ?? []).map((w) => w.slug))\n  for (const t of cfg.jobs?.tasks ?? []) {\n    if (workflows.has(t.slug)) {\n      throw new Error(`Task slug \"${t.slug}\" collides with a workflow slug`)\n    }\n  }\n}\n\nassertNoSlugCollision(config)","typeGuard":"function isUniqueAcross<T extends { slug: string }>(\n  a: T[],\n  b: T[],\n): boolean {\n  const set = new Set(a.map((x) => x.slug))\n  return b.every((x) => !set.has(x.slug))\n}\n\nif (!isUniqueCross(tasks, workflows)) {\n  throw new Error('task/workflow slug collision')\n}","tryCatchPattern":null,"preventionTips":["Add a config-build unit test that asserts no task slug equals a workflow slug.","Keep a single source of truth (constants) for job slugs to avoid drift.","Review slug changes in PRs that touch jobs config."],"tags":["jobs","queues","configuration","startup"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}