{"record":{"id":"1208175de2f966d6","repo":"mastra-ai/mastra","slug":"workflow-params-id-declares-an-array-of-sched","errorCode":null,"errorMessage":"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.","messagePattern":"Workflow \"(.+?)\" 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\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/evented/workflow.ts","lineNumber":1638,"sourceCode":"  TStateSchema extends PublicSchema<any> | undefined = undefined,\n  TSteps extends Step<string, any, any, any, any, any, EventedEngineType>[] = Step<\n    string,\n    any,\n    any,\n    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: {","sourceCodeStart":1620,"sourceCodeEnd":1656,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/evented/workflow.ts#L1620-L1656","documentation":"When defining a workflow with `schedule` given as an array, every entry must carry its own stable `id`. A plain `Error` is thrown during workflow construction because one of the array entries lacks an `id`. Single schedule objects are exempt (the workflow id identifies them), but arrays need per-entry ids so each schedule can be uniquely registered, updated, and cancelled.","triggerScenarios":"Calling `new Workflow({ id, schedule: [ { cron: '...' }, ... ] })` (or passing schedule through the params object) where at least one array element has no `id` property or an empty/falsy id (workflow.ts:1633-1646).","commonSituations":"Converting a single-schedule workflow to multiple schedules by wrapping the object in an array without adding ids; copy-pasting schedule entries and dropping the id; generating schedules dynamically and omitting the field.","solutions":["Add a unique, stable `id` string to every entry in the schedule array.","If there is only one schedule, pass a single schedule object instead of an array to avoid the id requirement.","Validate schedule entries at startup (map over the array and assert each has a truthy id) before constructing the workflow."],"exampleFix":"// before\nnew Workflow({ id: 'report', schedule: [{ cron: '0 * * * *' }, { cron: '0 12 * * *' }] });\n\n// after\nnew Workflow({ id: 'report', schedule: [\n  { id: 'hourly', cron: '0 * * * *' },\n  { id: 'noon', cron: '0 12 * * *' },\n] });","handlingStrategy":"validation","validationCode":"function assertScheduleIds(workflowId: string, schedule: unknown): void {\n  const entries = Array.isArray(schedule) ? schedule : [schedule];\n  for (const [i, e] of entries.entries()) {\n    if (typeof e !== 'object' || e === null || !('id' in e) || typeof (e as any).id !== 'string' || !(e as any).id) {\n      throw new Error(`Workflow \"${workflowId}\" schedule entry ${i} is missing a required string \"id\"`);\n    }\n  }\n}\nassertScheduleIds('report', schedule); // call before new Workflow(...)","typeGuard":"function hasScheduleId(e: unknown): e is { id: string; cron?: string; timezone?: string } {\n  return typeof e === 'object' && e !== null && typeof (e as any).id === 'string' && (e as any).id.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Give every schedule array entry an explicit, stable id at definition time.","Pass a single object (not a one-element array) when there is only one schedule.","Validate schedule config (ids, cron, timezone) in CI before deploying workflows."],"tags":["workflow","scheduling","configuration","validation"],"backgroundTag":"missing-required-field","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}