{"record":{"id":"31d419aaddd6fe5f","repo":"mastra-ai/mastra","slug":"schedules-not-found","errorCode":"SCHEDULES_NOT_FOUND","errorMessage":"Schedule \"${id}\" not found.","messagePattern":"Schedule \"(.+?)\" not found\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":404,"severity":"error","filePath":"packages/core/src/schedules/schedules.ts","lineNumber":445,"sourceCode":"      // `workflowId` filters at the store level, but an `agentId` filter must\n      // not surface workflow rows (and vice versa when both are set).\n      .filter(s => (filter?.agentId ? s.agentId !== undefined : true));\n    const agentOnly = filter?.threadId !== undefined || filter?.resourceId !== undefined || filter?.name !== undefined;\n    if (!agentOnly) return views;\n    return views.filter(s => {\n      if (s.agentId === undefined) return false;\n      if (filter?.threadId !== undefined && s.threadId !== filter.threadId) return false;\n      if (filter?.resourceId !== undefined && s.resourceId !== filter.resourceId) return false;\n      if (filter?.name !== undefined && s.name !== filter.name) return false;\n      return true;\n    });\n  }\n\n  async update(id: string, patch: UpdateScheduleInput): Promise<AnySchedule> {\n    const store = await this.#getStore();\n    const existing = await this.#load(id);\n    if (!existing) {\n      throw new MastraError({\n        id: 'SCHEDULES_NOT_FOUND',\n        domain: ErrorDomain.AGENT,\n        category: ErrorCategory.USER,\n        details: { status: 404 },\n        text: `Schedule \"${id}\" not found.`,\n      });\n    }\n\n    const nextCron = patch.cron ?? existing.cron;\n    const nextTimezone = patch.timezone !== undefined ? patch.timezone : existing.timezone;\n    if (patch.cron !== undefined || patch.timezone !== undefined) {\n      validateCron(nextCron, nextTimezone);\n    }\n\n    const nextTarget =\n      existing.target.type === 'agent'\n        ? this.#patchAgentTarget(existing.target, patch as UpdateAgentScheduleInput)\n        : this.#patchWorkflowTarget(existing.target, patch);","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/schedules/schedules.ts#L427-L463","documentation":"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.","triggerScenarios":"Calling schedules.update(id, patch) where no schedule with that id exists in storage (never created, already deleted, or wrong storage backend).","commonSituations":"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).","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."],"exampleFix":"// before\nawait schedules.update('daly-report', { cron: '0 7 * * *' });\n// after\nconst id = 'daily-report';\nif (!(await schedules.get(id))) throw new Error(`Schedule ${id} missing`);\nawait schedules.update(id, { cron: '0 7 * * *' });","handlingStrategy":"validation","validationCode":"const schedule = await schedules.get(id);\nif (!schedule) throw new Error(`Schedule ${id} not found`);\nawait schedules.update(id, patch);","typeGuard":null,"tryCatchPattern":"try {\n  await schedules.update(id, patch);\n} catch (e) {\n  if (String((e as Error).message).includes('not found')) {\n    // handle missing schedule: recreate, alert, or skip\n  } else throw e;\n}","preventionTips":["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."],"tags":["schedules","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}