{"record":{"id":"0d807fe84b6b542a","repo":"mastra-ai/mastra","slug":"schedules-invalid-workflow-patch","errorCode":"SCHEDULES_INVALID_WORKFLOW_PATCH","errorMessage":"schedules.update: ${offenders.join(', ')} only apply to agent schedules.","messagePattern":"schedules\\.update: (.+?) only apply to agent schedules\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":400,"severity":"error","filePath":"packages/core/src/schedules/schedules.ts","lineNumber":536,"sourceCode":"      ...(patch.ifActive !== undefined ? { ifActive: patch.ifActive } : {}),\n      ...(patch.ifIdle !== undefined ? { ifIdle: patch.ifIdle } : {}),\n    };\n  }\n\n  #patchWorkflowTarget(existingTarget: WorkflowTarget, patch: UpdateScheduleInput): WorkflowTarget {\n    const agentOnly = [\n      'prompt',\n      'name',\n      'signalType',\n      'tagName',\n      'attributes',\n      'providerOptions',\n      'ifActive',\n      'ifIdle',\n    ];\n    const offenders = agentOnly.filter(key => (patch as Record<string, unknown>)[key] !== undefined);\n    if (offenders.length > 0) {\n      throw new MastraError({\n        id: 'SCHEDULES_INVALID_WORKFLOW_PATCH',\n        domain: ErrorDomain.AGENT,\n        category: ErrorCategory.USER,\n        details: { status: 400 },\n        text: `schedules.update: ${offenders.join(', ')} only apply to agent schedules.`,\n      });\n    }\n    const wfPatch = patch as UpdateWorkflowScheduleInput;\n    return {\n      ...existingTarget,\n      ...(wfPatch.inputData !== undefined ? { inputData: wfPatch.inputData } : {}),\n      ...(wfPatch.initialState !== undefined ? { initialState: wfPatch.initialState } : {}),\n      ...(wfPatch.requestContext !== undefined ? { requestContext: wfPatch.requestContext } : {}),\n    };\n  }\n\n  async delete(id: string): Promise<void> {\n    const store = await this.#getStore();","sourceCodeStart":518,"sourceCodeEnd":554,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/schedules/schedules.ts#L518-L554","documentation":"update() was called on a workflow schedule with options that only apply to agent schedules (e.g. resourceId, providerOptions, ifActive, ifIdle). The library filters the patch for agent-only keys and throws a 400-class user error listing each offender.","triggerScenarios":"Calling schedules.update() on a workflow schedule (via nextTarget → #patchWorkflowTarget) where any key among the agent-only list ('providerOptions', 'ifActive', 'ifIdle', etc.) is !== undefined in the patch.","commonSituations":"Reusing one patch object for both agent and workflow schedules; copying an agent schedule's options onto a workflow schedule; generic update helpers that spread all fields.","solutions":["Strip agent-only options from the patch when updating a workflow schedule.","Branch your update code on schedule type and build a type-appropriate patch.","If the options are genuinely needed, recreate the target as an agent schedule with a threadId."],"exampleFix":"// before\nawait schedules.update('wf-job', { cron: '0 * * * *', ifIdle: 'cancel' }); // workflow schedule\n// after\nawait schedules.update('wf-job', { cron: '0 * * * *' });","handlingStrategy":"type-guard","validationCode":"const agentOnly = ['resourceId', 'providerOptions', 'signalType', 'ifActive', 'ifIdle'];\nif (schedule.type === 'workflow' && agentOnly.some(k => (patch as any)[k] !== undefined)) {\n  throw new Error('agent-only options on workflow schedule');\n}","typeGuard":"function isAgentOnlyPatch(patch: object): boolean {\n  return ['resourceId', 'providerOptions', 'signalType', 'ifActive', 'ifIdle'].some(k => (patch as Record<string, unknown>)[k] !== undefined);\n}\n// use: if (schedule.type === 'workflow' && isAgentOnlyPatch(patch)) reject;","tryCatchPattern":null,"preventionTips":["Use distinct TypeScript types for agent vs workflow schedule patches.","Never spread one generic patch object across both schedule kinds.","Filter agent-only keys out in shared update utilities based on schedule type."],"tags":["schedules","validation","workflow","update"],"backgroundTag":"invalid-option-combination","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}