mastra-ai/mastra · error · MastraError
SCHEDULES_INVALID_WORKFLOW_PATCH
SCHEDULES_INVALID_WORKFLOW_PATCH
Error message
schedules.update: ${offenders.join(', ')} only apply to agent schedules. What it means
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.
Source
Thrown at packages/core/src/schedules/schedules.ts:536
...(patch.ifActive !== undefined ? { ifActive: patch.ifActive } : {}),
...(patch.ifIdle !== undefined ? { ifIdle: patch.ifIdle } : {}),
};
}
#patchWorkflowTarget(existingTarget: WorkflowTarget, patch: UpdateScheduleInput): WorkflowTarget {
const agentOnly = [
'prompt',
'name',
'signalType',
'tagName',
'attributes',
'providerOptions',
'ifActive',
'ifIdle',
];
const offenders = agentOnly.filter(key => (patch as Record<string, unknown>)[key] !== undefined);
if (offenders.length > 0) {
throw new MastraError({
id: 'SCHEDULES_INVALID_WORKFLOW_PATCH',
domain: ErrorDomain.AGENT,
category: ErrorCategory.USER,
details: { status: 400 },
text: `schedules.update: ${offenders.join(', ')} only apply to agent schedules.`,
});
}
const wfPatch = patch as UpdateWorkflowScheduleInput;
return {
...existingTarget,
...(wfPatch.inputData !== undefined ? { inputData: wfPatch.inputData } : {}),
...(wfPatch.initialState !== undefined ? { initialState: wfPatch.initialState } : {}),
...(wfPatch.requestContext !== undefined ? { requestContext: wfPatch.requestContext } : {}),
};
}
async delete(id: string): Promise<void> {
const store = await this.#getStore();View on GitHub (pinned to 75dd419e61)
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.
Example fix
// before
await schedules.update('wf-job', { cron: '0 * * * *', ifIdle: 'cancel' }); // workflow schedule
// after
await schedules.update('wf-job', { cron: '0 * * * *' }); Defensive patterns
Strategy: type-guard
Validate before calling
const agentOnly = ['resourceId', 'providerOptions', 'signalType', 'ifActive', 'ifIdle'];
if (schedule.type === 'workflow' && agentOnly.some(k => (patch as any)[k] !== undefined)) {
throw new Error('agent-only options on workflow schedule');
} Type guard
function isAgentOnlyPatch(patch: object): boolean {
return ['resourceId', 'providerOptions', 'signalType', 'ifActive', 'ifIdle'].some(k => (patch as Record<string, unknown>)[k] !== undefined);
}
// use: if (schedule.type === 'workflow' && isAgentOnlyPatch(patch)) reject; Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- @mastra/livekit: `workflowInput` is required when `workflow`
- Dynamic workflow bundle contains more than one definition wi
- Dynamic workflow bundle has a circular nested-workflow depen
- SCHEDULES_INVALID_DEFINITION
- SCHEDULES_AMBIGUOUS_MODE
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/0d807fe84b6b542a.
Report an issue: GitHub.