{"record":{"id":"b8c949fa990c139f","repo":"mastra-ai/mastra","slug":"describebadplaceholder-template-idx-rawexpr-b8c949","errorCode":null,"errorMessage":"${describeBadPlaceholder(template, idx, rawExpr)} references unknown namespace \"${scope}\". Use one of: ${TEMPLATE_NAMESPACES.join(', ')}.","messagePattern":"(.+?) references unknown namespace \"(.+?)\"\\. Use one of: (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/mapping-template.ts","lineNumber":83,"sourceCode":"      const innerDot = rest.indexOf('.');\n      const stepId = innerDot === -1 ? rest : rest.slice(0, innerDot);\n      if (!stepId) {\n        throw new Error(\n          `${describeBadPlaceholder(template, idx, rawExpr)} must be of the form \\${stepResults.<stepId>} or \\${stepResults.<stepId>.<path>}.`,\n        );\n      }\n      continue;\n    }\n    if (scope === 'requestContext') {\n      if (!rest) {\n        throw new Error(\n          `${describeBadPlaceholder(template, idx, rawExpr)} requires a request-context key — use \\${requestContext.<key>}.`,\n        );\n      }\n      continue;\n    }\n    if ((TEMPLATE_NAMESPACES as readonly string[]).includes(scope)) continue;\n    throw new Error(\n      `${describeBadPlaceholder(template, idx, rawExpr)} references unknown namespace \"${scope}\". ` +\n        `Use one of: ${TEMPLATE_NAMESPACES.join(', ')}.`,\n    );\n  }\n}\n\n/**\n * Collects the step ids referenced by `${stepResults.<stepId>}` /\n * `${stepResults.<stepId>.<path>}` placeholders in a template. Assumes the\n * template already passed {@link validateTemplate}; malformed placeholders are\n * skipped. Used by validation to scope-check template references against the\n * preceding workflow-local steps.\n */\nexport function collectTemplateStepIds(template: string): string[] {\n  const ids: string[] = [];\n  for (const match of template.matchAll(TEMPLATE_PLACEHOLDER)) {\n    const { scope, rest } = parseTemplatePlaceholder(match[1] ?? '');\n    if (scope !== 'stepResults') continue;","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/mapping-template.ts#L65-L101","documentation":"Template placeholders must use one of the known TEMPLATE_NAMESPACES scopes (e.g. stepResults, requestContext, and other supported namespaces). An unrecognized scope like \"${input.foo}\" or \"${results.x}\" is rejected with the list of valid namespaces.","triggerScenarios":"Using an invented scope such as \"${input.value}\", \"${context.key}\", \"${results.myStep}\" in a mapping template; mixing up scope names from other libraries.","commonSituations":"Guessing scope names without checking docs; migrating templates from another workflow engine; typos like \"stepResult\" (singular).","solutions":["Use a valid namespace from the error message list, e.g. \"${stepResults.myStep.field}\" or \"${requestContext.key}\".","Fix near-miss typos (\"stepResult\" -> \"stepResults\").","Grep your codebase for '${' templates and lint them with validateTemplate() in CI."],"exampleFix":"// before\nmapVariable({ value: '${results.fetchUser.id}' });\n// after\nmapVariable({ value: '${stepResults.fetchUser.id}' });","handlingStrategy":"validation","validationCode":"const KNOWN = ['stepResults', 'requestContext' /* plus other TEMPLATE_NAMESPACES */];\nfor (const m of tpl.matchAll(/\\$\\{([^}]*)\\}/g)) {\n  const scope = m[1].split('.')[0];\n  if (!KNOWN.includes(scope)) throw new Error(`Unknown namespace '${scope}' in ${m[0]}; use one of ${KNOWN.join(', ')}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  validateTemplate(tpl);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('unknown namespace')) {\n    console.error(err.message); // lists valid namespaces to use\n  } else throw err;\n}","preventionTips":["Only use namespaces from the error's 'Use one of:' list.","Common near-miss: singular 'stepResult' instead of 'stepResults'.","Run validateTemplate() over all templates in CI."],"tags":["workflow","template","mapping","namespace"],"backgroundTag":"template-unknown-namespace","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}