{"record":{"id":"64c20d91368fa5d0","repo":"mastra-ai/mastra","slug":"mapping-references-unknown-workflow-init-data-s","errorCode":null,"errorMessage":"Mapping references unknown workflow init-data \"${source.initData}\".","messagePattern":"Mapping references unknown workflow init-data \"(.+?)\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/dynamic/rehydrate.ts","lineNumber":333,"sourceCode":" * step IDs because mapping execution resolves them from the run's step results.\n */\nfunction rehydrateMapConfig(cfg: Record<string, any>, mastra: Mastra): Record<string, any> {\n  const out: Record<string, any> = {};\n  for (const [key, source] of Object.entries(cfg)) {\n    if (!source || typeof source !== 'object') {\n      out[key] = source;\n      continue;\n    }\n    if ('template' in source) {\n      out[key] = { template: source.template };\n    } else if ('value' in source) {\n      out[key] = { value: source.value };\n    } else if ('requestContextPath' in source) {\n      out[key] = { requestContextPath: source.requestContextPath };\n    } else if ('initData' in source && typeof source.initData === 'string') {\n      const wf = mastra.getWorkflow?.(source.initData);\n      if (!wf) {\n        throw new Error(`Mapping references unknown workflow init-data \"${source.initData}\".`);\n      }\n      out[key] = mapVariable({ initData: wf as any, path: source.path });\n    } else if ('step' in source) {\n      out[key] = mapVariable({ step: source.step as any, path: source.path });\n    } else {\n      out[key] = source;\n    }\n  }\n  return out;\n}\n\n/**\n * Mastra.getAgentById throws when the id isn't registered; every by-id\n * resolution path in this file wants a nullable \"does it exist?\" answer so it\n * can fall through to a tool lookup or a targeted error. Swallow the not-found\n * throw and return undefined.\n */\nfunction tryGetAgentById(mastra: Mastra, id: string): any | undefined {","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/dynamic/rehydrate.ts#L315-L351","documentation":"A mapping source of kind `initData` references a workflow by id whose init-data provides the mapped value. During rehydration, `rehydrateMapConfig` looks up that workflow via `mastra.getWorkflow(source.initData)`; if it is not registered, the mapping cannot be resolved and the library throws.","triggerScenarios":"rehydrateWorkflow resolves a mapping config containing `{ initData: '<workflowId>' }` where no workflow with that id is registered on the current Mastra instance (typo, removed workflow, cross-environment registry mismatch).","commonSituations":"Renaming or deleting a workflow that other workflows' mappings depend on; deploying a stored workflow to a service missing the referenced workflow; copying graphs between projects.","solutions":["Register the referenced workflow on the Mastra instance: `new Mastra({ workflows: { '<initData id>': wf } })`.","Fix the stored `initData` id if it was renamed or is mistyped.","Share workflow registration across services that rehydrate the same stored graphs.","Pre-validate every mapping source: assert `mastra.getWorkflow(source.initData)` exists before rehydrating."],"exampleFix":"// before\nconst mastra = new Mastra({}); // mapping references initData 'sourceWf'\n\n// after\nconst mastra = new Mastra({ workflows: { sourceWf } });","handlingStrategy":"validation","validationCode":"function assertInitDataWorkflowsRegistered(stored, mastra) {\n  for (const e of stored.entries) {\n    if (e.type === 'mapping') {\n      for (const src of Object.values(e.config ?? {})) {\n        if (src && typeof src === 'object' && 'initData' in src && !mastra.getWorkflow?.(src.initData)) {\n          throw new Error(`initData workflow \"${src.initData}\" must be registered before rehydration`);\n        }\n      }\n    }\n  }\n}","typeGuard":"function initDataResolves(mastra: Mastra, source: unknown): boolean {\n  const s = source as any;\n  return !('initData' in (s ?? {})) || !!mastra.getWorkflow?.(s.initData);\n}","tryCatchPattern":"try {\n  const wf = rehydrateWorkflow(stored, mastra);\n} catch (err) {\n  const m = err instanceof Error && err.message.match(/unknown workflow init-data \"([^\"]+)\"/);\n  if (m) throw new Error(`Register workflow '${m[1]}' (init-data source) before rehydrating.`);\n  throw err;\n}","preventionTips":["Register every workflow used as an init-data mapping source on all rehydrating instances.","When renaming workflows, update all mapping initData references atomically.","Enumerate initData ids from stored graphs at deploy time and verify registration."],"tags":["workflow","mapping","registration","rehydration"],"backgroundTag":"unregistered-resource-reference","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}