{"record":{"id":"742055035132b540","repo":"mastra-ai/mastra","slug":"stored-sleep-entry-id-missing-literal-duratio","errorCode":null,"errorMessage":"Stored sleep \"${entry.id}\" missing literal duration.","messagePattern":"Stored sleep \"(.+?)\" missing literal duration\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/dynamic/rehydrate.ts","lineNumber":100,"sourceCode":"  wf: any,\n  entry: ValidatableStepFlowEntry,\n  mastra: Mastra,\n  schemaOpts?: JsonSchemaToZodOptions,\n): void {\n  switch (entry.type) {\n    case 'agent':\n    case 'tool':\n      wf.__pushStepFlowEntry(rehydrateSingleEntry(entry, mastra, schemaOpts), entry);\n      return;\n    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;","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/dynamic/rehydrate.ts#L82-L118","documentation":"When rehydrating a stored workflow, a `sleep` entry must carry a literal numeric duration (durations can't be recomputed from runtime state). If entry.duration is not a number, applyGraphEntry throws this error naming the stored step id.","triggerScenarios":"A stored workflow graph contains `{ type: 'sleep', id, duration: undefined/null/'30s' }` — e.g. the sleep was created from a dynamic value that was never serialized, the stored row is corrupted, or a hand-written definition used a non-numeric duration.","commonSituations":"Sleeps configured via a builder UI with a string like '30' or '30s' instead of a number; storage dropping the field; definitions hand-migrated from another format where duration was an object ({seconds: 30}).","solutions":["Fix the stored entry so duration is a literal number of milliseconds.","Re-save the workflow step through the builder API with a numeric duration.","Convert string/object durations to milliseconds when migrating stored definitions."],"exampleFix":"// before\n{ type: 'sleep', id: 'wait', duration: '30s' }\n// after\n{ type: 'sleep', id: 'wait', duration: 30000 }","handlingStrategy":"validation","validationCode":"function assertSleepEntry(entry) {\n  if (entry.type === 'sleep' && typeof entry.duration !== 'number') {\n    throw new TypeError(`Sleep step \"${entry.id}\" must have a numeric duration`);\n  }\n}","typeGuard":"function isValidSleepEntry(e: { type: string; duration?: unknown }): e is { type: 'sleep'; id: string; duration: number } {\n  return e.type === 'sleep' && typeof e.duration === 'number';\n}","tryCatchPattern":"try {\n  const wf = await rehydrateWorkflow(stored, mastra);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('missing literal duration')) {\n    // fix the stored sleep entry with a numeric duration and retry\n  }\n  throw e;\n}","preventionTips":["Always persist sleep durations as numeric milliseconds.","Reject non-numeric duration input in any builder UI.","Validate stored graph entries before rehydration.","Convert string/object durations at migration time, not runtime."],"tags":["workflow","persistence","validation"],"backgroundTag":"invalid-stored-workflow","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}