mastra-ai/mastra · error · MastraError
SCHEDULES_NOT_FOUND
SCHEDULES_NOT_FOUND
Error message
Schedule "${id}" not found. What it means
update() was called with an id that does not resolve to an existing schedule. The library loads the schedule before patching and throws a 404-class user error when #load returns nothing.
Source
Thrown at packages/core/src/schedules/schedules.ts:445
// `workflowId` filters at the store level, but an `agentId` filter must
// not surface workflow rows (and vice versa when both are set).
.filter(s => (filter?.agentId ? s.agentId !== undefined : true));
const agentOnly = filter?.threadId !== undefined || filter?.resourceId !== undefined || filter?.name !== undefined;
if (!agentOnly) return views;
return views.filter(s => {
if (s.agentId === undefined) return false;
if (filter?.threadId !== undefined && s.threadId !== filter.threadId) return false;
if (filter?.resourceId !== undefined && s.resourceId !== filter.resourceId) return false;
if (filter?.name !== undefined && s.name !== filter.name) return false;
return true;
});
}
async update(id: string, patch: UpdateScheduleInput): Promise<AnySchedule> {
const store = await this.#getStore();
const existing = await this.#load(id);
if (!existing) {
throw new MastraError({
id: 'SCHEDULES_NOT_FOUND',
domain: ErrorDomain.AGENT,
category: ErrorCategory.USER,
details: { status: 404 },
text: `Schedule "${id}" not found.`,
});
}
const nextCron = patch.cron ?? existing.cron;
const nextTimezone = patch.timezone !== undefined ? patch.timezone : existing.timezone;
if (patch.cron !== undefined || patch.timezone !== undefined) {
validateCron(nextCron, nextTimezone);
}
const nextTarget =
existing.target.type === 'agent'
? this.#patchAgentTarget(existing.target, patch as UpdateAgentScheduleInput)
: this.#patchWorkflowTarget(existing.target, patch);View on GitHub (pinned to 75dd419e61)
Solutions
- Verify the id via a list/get call on the same Schedules instance and correct the id.
- Confirm the Schedules instance is connected to the storage backend where the schedule was created.
- Create the schedule if it genuinely does not exist yet, instead of updating.
Example fix
// before
await schedules.update('daly-report', { cron: '0 7 * * *' });
// after
const id = 'daily-report';
if (!(await schedules.get(id))) throw new Error(`Schedule ${id} missing`);
await schedules.update(id, { cron: '0 7 * * *' }); Defensive patterns
Strategy: validation
Validate before calling
const schedule = await schedules.get(id);
if (!schedule) throw new Error(`Schedule ${id} not found`);
await schedules.update(id, patch); Try / catch
try {
await schedules.update(id, patch);
} catch (e) {
if (String((e as Error).message).includes('not found')) {
// handle missing schedule: recreate, alert, or skip
} else throw e;
} Prevention
- Resolve schedule ids from a shared constant or config, never hand-typed strings.
- Verify ids exist after deploys/migrations that may recreate schedules.
- Ensure all environments point at the same storage backend when sharing schedules.
When it happens
Trigger: Calling schedules.update(id, patch) where no schedule with that id exists in storage (never created, already deleted, or wrong storage backend).
Common situations: Typo in the schedule id; pointing at a different storage/database than the one that created the schedule; trying to update a schedule after it was removed by cleanup; environment mismatch (dev vs prod DB).
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Schedule ${id} not found
- Model "${modelId}" is not available. Available models: ${ids
- ACP connection is not initialized
- Model "${this.options.model}" is not available. Available mo
- ClaudeSDKAgent resumeData must include either sessionId or c
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/31d419aaddd6fe5f.
Report an issue: GitHub.