{"record":{"id":"3ece20a1ad3db6db","repo":"mastra-ai/mastra","slug":"template-slug-not-found-available-templates","errorCode":null,"errorMessage":"Template \"${slug}\" not found. Available templates: ${templates.map(t => t.slug).join(', ')}","messagePattern":"Template \"(.+?)\" not found\\. Available templates: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent-builder/src/utils.ts","lineNumber":250,"sourceCode":"      description: string;\n      githubUrl: string;\n      tags: string[];\n      agents: string[];\n      workflows: string[];\n      tools: string[];\n    }>;\n    return data;\n  } catch (error) {\n    throw new Error(`Failed to fetch Mastra templates: ${error instanceof Error ? error.message : String(error)}`);\n  }\n}\n\n// Helper to get a specific template by slug\nexport async function getMastraTemplate(slug: string) {\n  const templates = await fetchMastraTemplates();\n  const template = templates.find(t => t.slug === slug);\n  if (!template) {\n    throw new Error(`Template \"${slug}\" not found. Available templates: ${templates.map(t => t.slug).join(', ')}`);\n  }\n  return template;\n}\n\n// Git commit tracking utility\nexport async function logGitState(targetPath: string, label: string): Promise<void> {\n  try {\n    // Skip if not a git repo\n    if (!(await isInsideGitRepo(targetPath))) return;\n    const gitStatusResult = await git(targetPath, 'status', '--porcelain');\n    const gitLogResult = await git(targetPath, 'log', '--oneline', '-3');\n    const gitCountResult = await git(targetPath, 'rev-list', '--count', 'HEAD');\n\n    console.info(`📊 Git state ${label}:`);\n    console.info('Status:', gitStatusResult.stdout.trim() || 'Clean working directory');\n    console.info('Recent commits:', gitLogResult.stdout.trim());\n    console.info('Total commits:', gitCountResult.stdout.trim());\n  } catch (gitError) {","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/agent-builder/src/utils.ts#L232-L268","documentation":"getMastraTemplate looks up a template by slug in the list returned by fetchMastraTemplates and throws 'Template \"<slug>\" not found. Available templates: ...' when no entry matches. The error message enumerates valid slugs, making it self-diagnosing.","triggerScenarios":"Requesting a template (via the `template` tool or direct call) with a slug that does not exist in the fetched registry: a typo, a slug from an older/newer templates listing, or an assumption the slug equals the repo name rather than the registry's slug field.","commonSituations":"Agents hallucinating template slugs; hard-coded slugs from blog posts or old versions; the templates service updated its catalog so previously valid slugs disappeared; case sensitivity ('Weather-App' vs 'weather-app').","solutions":["Read the 'Available templates:' list in the error and use one of the listed slugs exactly","Call fetchMastraTemplates (or the templates tool) first and pick a slug from the live list at runtime","Check for typos and exact casing in the slug","If the slug worked before, refresh the templates list — the catalog may have changed; pin the agent-builder version matching that catalog"],"exampleFix":"// before\nconst tpl = await getMastraTemplate('weather-agent-template'); // guessed slug\n\n// after\nconst all = await fetchMastraTemplates();\nconst tpl = all.find(t => t.slug === 'weather-agent-template') ?? all[0];","handlingStrategy":"validation","validationCode":"const templates = await fetchMastraTemplates();\nconst valid = new Set(templates.map(t => t.slug));\nif (!valid.has(slug)) {\n  throw new Error(`Unknown template slug '${slug}'. Valid: ${[...valid].join(', ')}`);\n}\nconst template = await getMastraTemplate(slug);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fetch the live template list and select slugs from it rather than hard-coding","Match slug casing exactly","For agent-driven flows, pass the available slugs to the model as an allowlist"],"tags":["lookup","not-found","input-validation"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}