{"record":{"id":"d77ebaec4f36de7c","repo":"mastra-ai/mastra","slug":"schedule-id-not-found","errorCode":null,"errorMessage":"Schedule ${id} not found","messagePattern":"Schedule (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/storage/domains/schedules/inmemory.ts","lineNumber":77,"sourceCode":"    return rows.map(cloneRow);\n  }\n\n  async listDueSchedules(now: number, limit?: number): Promise<Schedule[]> {\n    const due: Schedule[] = [];\n    for (const row of this.db.schedules.values()) {\n      if (row.status === 'active' && row.nextFireAt <= now) {\n        due.push(row);\n      }\n    }\n    due.sort((a, b) => a.nextFireAt - b.nextFireAt);\n    const cap = limit ?? due.length;\n    return due.slice(0, cap).map(cloneRow);\n  }\n\n  async updateSchedule(id: string, patch: ScheduleUpdate): Promise<Schedule> {\n    const existing = this.db.schedules.get(id);\n    if (!existing) {\n      throw new Error(`Schedule ${id} not found`);\n    }\n    const updated: Schedule = {\n      ...existing,\n      ...patch,\n      target: patch.target !== undefined ? patch.target : existing.target,\n      metadata: patch.metadata !== undefined ? patch.metadata : existing.metadata,\n      updatedAt: Date.now(),\n    };\n    const stored = clone(updated);\n    this.db.schedules.set(id, stored);\n    return cloneRow(stored);\n  }\n\n  async updateScheduleNextFire(\n    id: string,\n    expectedNextFireAt: number,\n    newNextFireAt: number,\n    lastFireAt: number,","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/storage/domains/schedules/inmemory.ts#L59-L95","documentation":"InMemoryScheduleStorage.updateSchedule() throws when no schedule with the given id exists in the store. The in-memory implementation has no upsert mode; updates apply only to existing schedules so callers can distinguish typos/deleted ids from successful patches.","triggerScenarios":"Calling updateSchedule('sched-1', { enabled: false }) after the schedule was never created, was deleted, or the store was cleared; using an id from a different storage instance or an old serialized reference.","commonSituations":"Disabling a schedule that a previous process run created but this run didn't; test teardown clearing schedules while a handler still holds the id; id typos or truncated ids from logs.","solutions":["Create the schedule before updating it, or switch the flow to createSchedule on absence.","Look up the schedule first (listSchedules / getSchedule) and handle the missing case explicitly.","Ensure the same storage instance is used for create and update (in-memory stores don't share state).","Log/inspect the exact id being passed; fix typos or stale serialized ids."],"exampleFix":"// before\nawait storage.schedules.updateSchedule('nightly-job', { enabled: false });\n// after\ntry {\n  await storage.schedules.updateSchedule('nightly-job', { enabled: false });\n} catch {\n  await storage.schedules.createSchedule({ id: 'nightly-job', enabled: false, ...baseDef });\n}","handlingStrategy":"try-catch","validationCode":"const all = await storage.schedules.listSchedules();\nif (!all.schedules?.some(s => s.id === id)) {\n  throw new Error(`cannot update: schedule ${id} does not exist`);\n}","typeGuard":"function findSchedule(schedules: { id: string }[], id: string): { id: string } | undefined {\n  return schedules.find(s => s.id === id);\n}","tryCatchPattern":"try {\n  return await storage.schedules.updateSchedule(id, patch);\n} catch (e) {\n  if (e instanceof Error && e.message === `Schedule ${id} not found`) {\n    throw new Error(`Schedule ${id} was never created in this storage instance; call createSchedule first`);\n  }\n  throw e;\n}","preventionTips":["Create schedules before updating them; treat update as strictly follow-up.","Use the same storage instance for create and update — in-memory state is not shared.","Beware test teardown clearing schedules while later code still references ids.","Log the exact id on failure to catch typos or truncated ids."],"tags":["storage","not-found","schedules","in-memory"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}