{"record":{"id":"88db2f573d965fb8","repo":"mastra-ai/mastra","slug":"label-references-unknown-namespace-scope","errorCode":null,"errorMessage":"${label} references unknown namespace \"${scope}\". Use one of: ${TEMPLATE_NAMESPACES.join(', ')}.","messagePattern":"(.+?) references unknown namespace \"(.+?)\"\\. Use one of: (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/mapping-template.ts","lineNumber":182,"sourceCode":"      const subPath = innerDot === -1 ? '' : rest.slice(innerDot + 1);\n      const stepResult = ctx.getStepResult(stepId);\n      // Nullish (not just null) so a step that \"succeeded\" with `undefined`\n      // output is reported as missing too — consistent with how predicates\n      // treat nullish step results. Nullish *path values inside* a present\n      // result still render as '' via stringifyTemplateValue.\n      if (stepResult == null) {\n        throw new Error(\n          `${label} references stepResults.${stepId} but step \"${stepId}\" has no successful output ` +\n            `(not run yet, not registered, failed, or produced no output).`,\n        );\n      }\n      return stringifyTemplateValue(traverseMappingPath(stepResult, subPath, label), template, idx, rawExpr);\n    }\n    default:\n      // validateTemplate guarantees this branch is unreachable for well-formed\n      // workflows; this is a safety net for templates that bypassed validation\n      // (e.g. constructed programmatically and pushed into stepFlow).\n      throw new Error(\n        `${label} references unknown namespace \"${scope}\". Use one of: ${TEMPLATE_NAMESPACES.join(', ')}.`,\n      );\n  }\n}\n","sourceCodeStart":164,"sourceCodeEnd":187,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/mapping-template.ts#L164-L187","documentation":"Thrown by resolveTemplatePlaceholder when a mapping template placeholder references a namespace scope that is not one of the known TEMPLATE_NAMESPACES. validateTemplate normally rejects malformed templates, so this is a safety net for templates constructed programmatically and injected into stepFlow without validation.","triggerScenarios":"Calling resolveTemplate (which calls resolveTemplatePlaceholder) with a template whose placeholder uses an unrecognized prefix, e.g. '{{foo.stepId.output}}' instead of a known namespace like '{{'steps.'...}}'. Typically only reachable by constructing template objects programmatically and pushing them into stepFlow, bypassing validateTemplate.","commonSituations":"Hand-written or generated mapping templates with typos in the namespace prefix; templates copied from older docs or another library's syntax; programmatic template generation that emits an invalid scope.","solutions":["Check the placeholder namespace prefix against the list printed in the error (TEMPLATE_NAMESPACES.join(', ')) and correct it.","Fix the typo in the template string (e.g. 'step' vs 'steps').","Ensure any programmatically built templates pass through validateTemplate before entering stepFlow.","Log the full template string at construction time to catch malformed scopes early."],"exampleFix":"// before\nconst tmpl = '{{stepsData.stepOne.output}}';\n// after\nconst tmpl = '{{steps.stepOne.output}}';","handlingStrategy":"validation","validationCode":"const KNOWN = ['steps','trigger',' inputData','context']; // TEMPLATE_NAMESPACES\nfunction validateNs(t: string) { const m = t.match(/\\{\\{(\\w+)\\./); if (!m || !KNOWN.includes(m[1])) throw new Error(`Unknown template namespace in: ${t}`); }","typeGuard":null,"tryCatchPattern":"try {\n  resolveTemplate(tpl, ctx);\n} catch (e) {\n  if ((e as Error).message.includes('references unknown namespace')) {\n    console.error('Fix template namespace:', tpl);\n  } else throw e;\n}","preventionTips":["Always pass programmatically built templates through validateTemplate before inserting into stepFlow","Keep placeholder prefixes consistent with the documented TEMPLATE_NAMESPACES","Add unit tests for every template string used in the workflow","Lint template strings for the known namespace prefixes"],"tags":["workflows","mapping-template","template-validation"],"backgroundTag":"unknown-template-namespace","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}