{"record":{"id":"035faba5009c386d","repo":"mastra-ai/mastra","slug":"stored-sleepuntil-entry-id-missing-literal-da","errorCode":null,"errorMessage":"Stored sleepUntil \"${entry.id}\" missing literal date.","messagePattern":"Stored sleepUntil \"(.+?)\" missing literal date\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/dynamic/rehydrate.ts","lineNumber":110,"sourceCode":"    case 'mapping': {\n      const cfg = parseMapConfig(entry.mapConfig, entry.id);\n      const live = rehydrateMapConfig(cfg, mastra);\n      wf.map(live, { id: entry.id });\n      return;\n    }\n    case 'sleep': {\n      if (typeof entry.duration !== 'number') {\n        throw new Error(`Stored sleep \"${entry.id}\" missing literal duration.`);\n      }\n      // Push directly (not wf.sleep()) so the stored step id survives the\n      // round-trip — the builder generates a fresh random id per call.\n      const live: StepFlowEntry = { type: 'sleep', id: entry.id, duration: entry.duration };\n      wf.__pushStepFlowEntry(live, live);\n      return;\n    }\n    case 'sleepUntil': {\n      if (!(entry.date instanceof Date) && typeof entry.date !== 'string') {\n        throw new Error(`Stored sleepUntil \"${entry.id}\" missing literal date.`);\n      }\n      const date = entry.date instanceof Date ? entry.date : new Date(entry.date);\n      if (Number.isNaN(date.getTime())) {\n        throw new Error(`Stored sleepUntil \"${entry.id}\" has an unparseable date: ${String(entry.date)}`);\n      }\n      const live: StepFlowEntry = { type: 'sleepUntil', id: entry.id, date };\n      wf.__pushStepFlowEntry(live, { type: 'sleepUntil', id: entry.id, date });\n      return;\n    }\n    case 'parallel': {\n      const live: StepFlowEntry = {\n        type: 'parallel',\n        steps: entry.steps.map(s => rehydrateSingleEntry(s, mastra, schemaOpts)),\n      };\n      wf.__pushStepFlowEntry(live, entry);\n      return;\n    }\n    case 'foreach': {","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/dynamic/rehydrate.ts#L92-L128","documentation":"For a stored `sleepUntil` entry, rehydration requires a literal date as a Date instance or a string; Date objects can't survive JSON serialization, so stored graphs normally carry strings. If entry.date is neither (undefined, number, null), applyGraphEntry throws this error.","triggerScenarios":"A stored workflow graph has `{ type: 'sleepUntil', id, date: 1735689600000 }` (number), missing date, or null — typically because serialization dropped the Date, or a hand-built definition used a timestamp number instead of an ISO string.","commonSituations":"Custom storage adapters serializing dates to numbers; hand-authored definitions passing epoch millis; migrations converting date strings to Date objects prematurely and then failing storage round-trips.","solutions":["Store/pass the date as an ISO 8601 string (or a live Date when constructing in memory).","Fix the corrupted stored entry for the named step id.","Update custom storage serialization to persist sleepUntil dates as strings."],"exampleFix":"// before\n{ type: 'sleepUntil', id: 'wait', date: 1735689600000 }\n// after\n{ type: 'sleepUntil', id: 'wait', date: '2025-01-01T00:00:00.000Z' }","handlingStrategy":"validation","validationCode":"function assertSleepUntilEntry(entry) {\n  if (entry.type === 'sleepUntil' && !(entry.date instanceof Date) && typeof entry.date !== 'string') {\n    throw new TypeError(`sleepUntil step \"${entry.id}\" must have a Date or ISO string date`);\n  }\n}","typeGuard":"function hasValidSleepUntilDate(e: { date?: unknown }): e is { date: Date | string } {\n  return e.date instanceof Date || typeof e.date === 'string';\n}","tryCatchPattern":"try {\n  const wf = await rehydrateWorkflow(stored, mastra);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('missing literal date')) {\n    // repair the stored entry to carry an ISO string date and retry\n  }\n  throw e;\n}","preventionTips":["Persist sleepUntil dates as ISO 8601 strings (Dates don't survive JSON).","Ensure custom storage adapters serialize dates to strings, not numbers.","Validate entry shapes before storing workflow graphs.","Test the storage round-trip for sleepUntil steps."],"tags":["workflow","persistence","date"],"backgroundTag":"invalid-stored-workflow","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}