{"record":{"id":"ca59bcf1b71ca863","repo":"mastra-ai/mastra","slug":"workflow-params-id-declares-duplicate-schedul","errorCode":null,"errorMessage":"Workflow \"${params.id}\" declares duplicate schedule id \"${entry.id}\".","messagePattern":"Workflow \"(.+?)\" declares duplicate schedule id \"(.+?)\"\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/evented/workflow.ts","lineNumber":1643,"sourceCode":"    any,\n    any,\n    any,\n    EventedEngineType\n  >[],\n  TRequestContextSchema extends PublicSchema<any> | undefined = undefined,\n>(params: CreateWorkflowParams<TWorkflowId, TStateSchema, TInputSchema, TOutputSchema, TSteps, TRequestContextSchema>) {\n  if (params.schedule) {\n    const schedules = Array.isArray(params.schedule) ? params.schedule : [params.schedule];\n    if (Array.isArray(params.schedule)) {\n      const seenIds = new Set<string>();\n      for (const entry of schedules) {\n        if (!entry.id) {\n          throw new Error(\n            `Workflow \"${params.id}\" declares an array of schedules but one entry is missing the required \\`id\\` field. Every entry in a schedule array must have a unique stable id.`,\n          );\n        }\n        if (seenIds.has(entry.id)) {\n          throw new Error(`Workflow \"${params.id}\" declares duplicate schedule id \"${entry.id}\".`);\n        }\n        seenIds.add(entry.id);\n      }\n    }\n    for (const entry of schedules) {\n      validateCron(entry.cron, entry.timezone);\n    }\n  }\n  const eventProcessor = new WorkflowEventProcessor({ mastra: params.mastra! });\n  const executionEngine = new EventedExecutionEngine({\n    mastra: params.mastra!,\n    eventProcessor,\n    options: {\n      validateInputs: params.options?.validateInputs ?? true,\n      shouldPersistSnapshot: params.options?.shouldPersistSnapshot ?? (() => true),\n      pruneSnapshot: params.options?.pruneSnapshot,\n      tracingPolicy: params.options?.tracingPolicy,\n      onStart: params.options?.onStart,","sourceCodeStart":1625,"sourceCodeEnd":1661,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/evented/workflow.ts#L1625-L1661","documentation":"When a workflow's `schedule` is an array, ids must be unique across entries; a duplicate id is detected with a `seenIds` Set and a plain `Error` is thrown. Duplicate ids would make it ambiguous which cron/timezone definition a registration refers to, breaking schedule updates and cancellation.","triggerScenarios":"`new Workflow({ id, schedule: [ { id: 'a', cron }, { id: 'a', cron } ] })` — the second entry's id is already in `seenIds` (workflow.ts:1641-1649).","commonSituations":"Copy-pasting a schedule entry and forgetting to change the id; merging schedule lists from config or environment where entries share defaults; template code that clones entries.","solutions":["Rename one of the conflicting entries so every id in the array is unique.","Generate deterministic distinct ids programmatically when building schedules dynamically (e.g. suffix by index or purpose).","Pre-validate the array with a Set-based uniqueness check before constructing the workflow to fail fast with a clearer message."],"exampleFix":"// before\nschedule: [{ id: 'sync', cron: '0 * * * *' }, { id: 'sync', cron: '*/5 * * * *' }]\n\n// after\nschedule: [{ id: 'sync-hourly', cron: '0 * * * *' }, { id: 'sync-every-5m', cron: '*/5 * * * *' }]","handlingStrategy":"validation","validationCode":"function assertUniqueScheduleIds(workflowId: string, schedule: unknown): void {\n  if (!Array.isArray(schedule)) return;\n  const seen = new Set<string>();\n  for (const e of schedule) {\n    if (seen.has(e.id)) throw new Error(`Workflow \"${workflowId}\" has duplicate schedule id \"${e.id}\"`);\n    seen.add(e.id);\n  }\n}\nassertUniqueScheduleIds('report', schedule);","typeGuard":"function idsAreUnique(entries: { id: string }[]): entries is { id: string }[] {\n  return new Set(entries.map(e => e.id)).size === entries.length;\n}","tryCatchPattern":null,"preventionTips":["Derive schedule ids from purpose (e.g. 'sync-hourly') so collisions are unlikely.","Run uniqueness checks where schedule arrays are generated from config/env.","Code-review any copy-pasted schedule entries for unchanged ids."],"tags":["workflow","scheduling","configuration","validation"],"backgroundTag":"duplicate-identifier","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}