{"record":{"id":"09ae381f7fba9e57","repo":"mastra-ai/mastra","slug":"runid-required-to-time-travel-workflow","errorCode":null,"errorMessage":"runId required to time travel workflow","messagePattern":"runId required to time travel workflow","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"packages/server/src/server/handlers/workflows.ts","lineNumber":1157,"sourceCode":"  responseType: 'json',\n  pathParamSchema: workflowIdPathParams,\n  queryParamSchema: runIdSchema,\n  bodySchema: timeTravelBodySchema,\n  responseSchema: workflowExecutionResultSchema,\n  summary: 'Time travel workflow asynchronously',\n  description: 'Time travels a workflow run asynchronously without streaming',\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' });\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      const run = await workflow.getWorkflowRunById(runId);\n\n      if (!run) {\n        throw new HTTPException(404, { message: 'Workflow run not found' });\n      }\n\n      await validateRunOwnership(run, effectiveResourceId);\n\n      const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n      const result = await _run.timeTravel({ ...params, requestContext });","sourceCodeStart":1139,"sourceCodeEnd":1175,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/workflows.ts#L1139-L1175","documentation":"POST /workflows/:workflowId/time-travel-async returns 400 with this message when the runId query parameter is missing. Time travel always operates on an existing run, so the handler rejects requests without runId before doing any lookup.","triggerScenarios":"POST /workflows/:workflowId/time-travel-async without the ?runId= query param (runIdSchema query param absent, null, or empty string).","commonSituations":"Forgetting the query param while testing with curl/Postman; client code passes runId in the body instead of the query string; runId variable undefined at call time.","solutions":["Append ?runId=<runId> to the request URL","Verify the runId value is defined and non-empty before issuing the request","Use the run id returned by workflow.createRun() or from the stored run, not the workflow id"],"exampleFix":"// before\nawait fetch(`/api/workflows/${workflowId}/time-travel-async`, { method: 'POST', body });\n// after\nawait fetch(`/api/workflows/${workflowId}/time-travel-async?runId=${runId}`, { method: 'POST', body });","handlingStrategy":"validation","validationCode":"if (!runId) throw new Error('runId is required');\nconst url = `/api/workflows/${workflowId}/time-travel-async?runId=${encodeURIComponent(runId)}`;","typeGuard":"function hasRunId(v: unknown): v is string {\n  return typeof v === 'string' && v.length > 0;\n}","tryCatchPattern":"try {\n  return await timeTravelAsync(workflowId, runId);\n} catch (e) {\n  if (isHttpError(e) && e.status === 400 && /runId required/.test(e.message)) {\n    console.error('Missing runId query param:', { workflowId, runId });\n  }\n  throw e;\n}","preventionTips":["Always pass runId as a query param, not in the body, for time-travel routes","Capture the run id returned by createRun() and persist it","Validate runId is non-empty before constructing the URL"],"tags":["http-400","validation","workflow","rest-api"],"backgroundTag":"missing-required-parameter","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}