{"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":"Error","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/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/ruvector/agent-wasm.ts#L402-L438","documentation":"Thrown by createAgentFromTemplate(templateId) when getGalleryTemplate(templateId) returns null. getGalleryTemplate wraps WasmGallery.get() in try/catch because the WASM gallery panics on unknown IDs in v0.1.0, so null covers both 'not found' and 'gallery.get threw'. This is the agent-from-template convenience constructor; failure means the template ID isn't in the bundled or custom gallery.","triggerScenarios":"templateId doesn't exist in the gallery (typo, wrong case); the gallery hasn't been seeded with custom templates; the WASM gallery object panicked (swallowed to null); calling before getGallery() has been initialized.","commonSituations":"Hardcoding a template ID that was renamed in a newer rvagent-wasm release; passing a user-supplied ID without validation; gallery custom-import failed silently so the expected template isn't present.","solutions":["Call listGalleryTemplates() (or searchGalleryTemplates(q)) first and confirm the ID exists; surface the list of valid IDs to the caller.","If using a custom template, ensure galleryAddCustom / galleryImportCustom succeeded before referencing it.","Treat a null result from getGalleryTemplate as authoritative — do not retry the WASM call directly (it may panic)."],"exampleFix":"// before\nconst info = await createAgentFromTemplate('coder-pro');\n\n// after — validate against the live gallery\nconst valid = (await listGalleryTemplates()).map(t => t.id);\nif (!valid.includes('coder-pro')) {\n  throw new Error(`unknown template 'coder-pro'. available: ${valid.join(', ')}`);\n}\nconst info = await createAgentFromTemplate('coder-pro');","handlingStrategy":"validation","validationCode":"async function assertTemplateExists(templateId: string): Promise<void> {\n  const valid = (await listGalleryTemplates()).map(t => t.id);\n  if (!valid.includes(templateId)) {\n    throw new Error(`template '${templateId}' not in gallery. available: ${valid.join(', ')}`);\n  }\n}\n\nawait assertTemplateExists('coder-pro');\nconst info = await createAgentFromTemplate('coder-pro');","typeGuard":"async function templateExists(id: string): Promise<boolean> {\n  return (await getGalleryTemplate(id)) !== null;\n}","tryCatchPattern":"try {\n  return await createAgentFromTemplate(id);\n} catch (e) {\n  if (/Gallery template not found/.test(String(e))) {\n    const valid = (await listGalleryTemplates()).map(t => t.id);\n    throw new Error(`${e.message}. available: ${valid.join(', ')}`);\n  }\n  throw e;\n}","preventionTips":["Always validate against listGalleryTemplates() before using a template ID — never trust a hardcoded or user-supplied ID.","Run galleryImportCustom in the same process before referencing custom templates.","Don't call WasmGallery.get() directly to 'check' — it panics on unknown IDs in v0.1.0; use getGalleryTemplate (which swallows the panic)."],"tags":["gallery","templates","wasm","agent-lifecycle"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}