{"record":{"id":"e9a6f514a555b8cc","repo":"mastra-ai/mastra","slug":"runid-required-to-time-travel-workflow-stream","errorCode":null,"errorMessage":"runId required to time travel workflow stream","messagePattern":"runId required to time travel workflow stream","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"packages/server/src/server/handlers/workflows.ts","lineNumber":1257,"sourceCode":"  path: '/workflows/:workflowId/time-travel-stream',\n  responseType: 'stream',\n  pathParamSchema: workflowIdPathParams,\n  queryParamSchema: runIdSchema,\n  bodySchema: timeTravelBodySchema,\n  summary: 'Time travel workflow stream',\n  description: 'Time travels a workflow run, starting from a specific step, and streams the results in real-time',\n  tags: ['Workflows'],\n  requiresAuth: true,\n  handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n    try {\n      const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n      if (!workflowId) {\n        throw new HTTPException(400, { message: 'Workflow ID is required' });\n      }\n\n      if (!runId) {\n        throw new HTTPException(400, { message: 'runId required to time travel workflow stream' });\n      }\n\n      const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n      if (!workflow) {\n        throw new HTTPException(404, { message: 'Workflow not found' });\n      }\n\n      // Validate ownership of existing run before time traveling\n      const existingRun = await workflow.getWorkflowRunById(runId);\n      if (!existingRun) {\n        throw new HTTPException(404, { message: 'Workflow run not found' });\n      }\n      await validateRunOwnership(existingRun, effectiveResourceId);\n\n      const serverCache = mastra.getServerCache();\n\n      const run = await workflow.createRun({ runId, resourceId: existingRun.resourceId });","sourceCodeStart":1239,"sourceCodeEnd":1275,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/workflows.ts#L1239-L1275","documentation":"This 400 error is thrown by the time-travel workflow stream handler when the request omits the `runId` path/body parameter. Time traveling a workflow stream requires identifying the specific existing run whose stream should be replayed; without a runId the server cannot locate or recreate the run stream, so it rejects the request before doing any work.","triggerScenarios":"Calling the time-travel workflow stream endpoint (e.g. POST /api/workflows/:workflowId/stream-v2/time-travel or equivalent) without providing `runId`, or providing it under a wrong key so the handler destructures it as undefined.","commonSituations":"Client SDK calls built by hand that forget the runId field; frontend code that navigates to time-travel before a runId has been selected; API route changes between server versions where the parameter moved from query string to body.","solutions":["Include the `runId` of the existing workflow run in the request (path or body, matching the route definition).","Fetch the runId first via the workflow runs list endpoint (GET workflow runs) if you don't have it.","Update client SDK code so the runId is passed with the documented parameter name.","Check the server route definition in packages/server/src/server/handlers/workflows.ts to confirm the expected parameter shape."],"exampleFix":"// before\nawait fetch(`/api/workflows/${workflowId}/stream-v2/time-travel`, { method: 'POST', body: JSON.stringify({ stepId }) });\n// after\nawait fetch(`/api/workflows/${workflowId}/stream-v2/time-travel`, { method: 'POST', body: JSON.stringify({ runId, stepId }) });","handlingStrategy":"validation","validationCode":"if (!runId) throw new Error('timeTravel requires a runId obtained from the workflow run');","typeGuard":"function hasRunId(params: { runId?: string }): params is { runId: string } {\n  return typeof params.runId === 'string' && params.runId.length > 0;\n}","tryCatchPattern":"try {\n  await client.getWorkflow(wfId).timeTravel({ runId, stepId, context });\n} catch (e) {\n  if (e?.status === 400 && /runId required/.test(e?.message ?? '')) {\n    throw new Error('Provide the runId of an existing workflow run to time travel');\n  }\n  throw e;\n}","preventionTips":["Store the runId returned by start()/startAsync for later time-travel calls.","Validate request parameters client-side before calling the API.","Use the typed @mastra/client-js SDK methods instead of hand-built URLs.","Keep client SDK and server versions in sync so parameter names match."],"tags":["http-400","validation","workflow","missing-parameter"],"backgroundTag":"missing-required-parameter","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}