{"record":{"id":"56f4a488b08c9ab0","repo":"ruvnet/ruflo","slug":"gallery-template-not-found-templateid","errorCode":null,"errorMessage":"Gallery template not found: ${templateId}","messagePattern":"Gallery template not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/ruvector/agent-wasm.ts","lineNumber":420,"sourceCode":"/**\n * Get a gallery template by id.\n * Wraps in try/catch because WasmGallery.get() panics on unknown IDs in v0.1.0.\n */\nexport async function getGalleryTemplate(id: string): Promise<GalleryTemplateDetail | null> {\n  const gallery = await getGallery();\n  try {\n    return gallery.get(id) ?? null;\n  } catch {\n    return null;\n  }\n}\n\n/**\n * Create an agent from a gallery template.\n */\nexport async function createAgentFromTemplate(templateId: string): Promise<WasmAgentInfo> {\n  const template = await getGalleryTemplate(templateId);\n  if (!template) throw new Error(`Gallery template not found: ${templateId}`);\n\n  const systemPrompt = template.prompts?.[0]?.system_prompt;\n  return createWasmAgent({\n    instructions: systemPrompt ?? `You are a ${template.name}.`,\n    model: undefined, // Use default\n  });\n}\n\n// ── RVF Container Operations ─────────────────────────────────\n\nexport interface McpToolDescriptor {\n  name: string;\n  description: string;\n  input_schema: unknown;\n  group?: string;\n}\n\n/**","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/ruvector/agent-wasm.ts#L402-L438","documentation":"createAgentFromTemplate(templateId) resolves the id through getGalleryTemplate, which returns null when the WASM gallery has no such template or the lookup itself throws (errors are swallowed to null). A null template becomes this thrown Error before any agent is constructed.","triggerScenarios":"Passing an id that is not in the gallery (typo, wrong casing); calling before initAgentWasm()/gallery initialization so lookups fail; referencing a custom template that was removed via galleryRemoveCustom; using an id from a different @ruvector/rvagent-wasm version whose gallery contents changed.","commonSituations":"Hardcoding template names that drift across package versions; user-supplied template ids from a form or API; assuming a custom template persisted across reinstalls (custom gallery state is not part of node_modules).","solutions":["Discover valid ids at runtime: listGalleryTemplates() or searchGalleryTemplates(query) (agent-wasm.ts:373/397)","Pre-check with getGalleryTemplate(templateId) — null reliably predicts this throw","Ensure initAgentWasm() succeeded (isAgentWasmAvailable()) before template calls","For custom templates, re-add them with galleryAddCustom or re-import via galleryImportCustom after reinstall"],"exampleFix":"// before\nconst info = await createAgentFromTemplate('code-writter'); // typo\n// after\nimport { getGalleryTemplate, listGalleryTemplates, createAgentFromTemplate } from './agent-wasm';\nconst id = 'code-writer';\nif (!(await getGalleryTemplate(id))) {\n  throw new Error(`unknown template; have: ${(await listGalleryTemplates()).map(t => t.id).join(', ')}`);\n}\nconst info = await createAgentFromTemplate(id);","handlingStrategy":"validation","validationCode":"import { getGalleryTemplate, listGalleryTemplates } from './agent-wasm';\nasync function assertTemplate(id: string): Promise<void> {\n  if (!(await getGalleryTemplate(id))) {\n    const have = (await listGalleryTemplates()).map(t => t.id).join(', ');\n    throw new Error(`template '${id}' not in gallery. Available: ${have}`);\n  }\n}","typeGuard":"import { getGalleryTemplate } from './agent-wasm';\nasync function templateExists(id: string): Promise<boolean> {\n  return (await getGalleryTemplate(id)) != null;\n}","tryCatchPattern":"try {\n  info = await createAgentFromTemplate(id);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Gallery template not found')) {\n    // surface available ids, or fall back to a default template\n    info = await createAgentFromTemplate('default');\n  } else throw e;\n}","preventionTips":["Derive template ids from listGalleryTemplates()/searchGalleryTemplates(), never hardcode","Treat template ids as version-dependent — re-validate after upgrading @ruvector/rvagent-wasm","Re-import custom templates (galleryImportCustom) as part of environment setup"],"tags":["wasm","gallery","template","invalid-id"],"backgroundTag":"template-not-found","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}