{"record":{"id":"8ec1caa86f21ba09","repo":"ruvnet/ruflo","slug":"template-not-found-id","errorCode":null,"errorMessage":"Template not found: ${id}","messagePattern":"Template not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ruflo/src/ruvocal/src/lib/wasm/index.ts","lineNumber":1015,"sourceCode":"\t\t}\n\n\t\tsearch(query: string): SearchResult[] {\n\t\t\tconst q = query.toLowerCase();\n\t\t\treturn builtinTemplates\n\t\t\t\t.filter((t) => t.name.toLowerCase().includes(q) || t.description.toLowerCase().includes(q) || t.tags.some((tag) => tag.toLowerCase().includes(q)))\n\t\t\t\t.map((t) => ({\n\t\t\t\t\tid: t.id,\n\t\t\t\t\tname: t.name,\n\t\t\t\t\tdescription: t.description,\n\t\t\t\t\tcategory: t.category,\n\t\t\t\t\ttags: t.tags,\n\t\t\t\t\trelevance: t.name.toLowerCase().includes(q) ? 1.0 : 0.5,\n\t\t\t\t}));\n\t\t}\n\n\t\tget(id: string): GalleryTemplate {\n\t\t\tconst template = builtinTemplates.find((t) => t.id === id);\n\t\t\tif (!template) throw new Error(`Template not found: ${id}`);\n\t\t\treturn template;\n\t\t}\n\n\t\tloadRvf(id: string): Uint8Array {\n\t\t\tconst template = this.get(id);\n\t\t\t// Return mock RVF bytes (magic + version + minimal content)\n\t\t\tconst encoder = new TextEncoder();\n\t\t\tconst json = JSON.stringify(template);\n\t\t\tconst jsonBytes = encoder.encode(json);\n\t\t\tconst rvf = new Uint8Array(8 + jsonBytes.length);\n\t\t\trvf.set([0x52, 0x56, 0x46, 0x00, 0x01, 0x00, 0x00, 0x00]); // RVF\\0 + version\n\t\t\trvf.set(jsonBytes, 8);\n\t\t\treturn rvf;\n\t\t}\n\n\t\tsetActive(id: string): void {\n\t\t\tactiveTemplateId = id;\n\t\t}","sourceCodeStart":997,"sourceCodeEnd":1033,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/ruflo/src/ruvocal/src/lib/wasm/index.ts#L997-L1033","documentation":"Thrown by WasmGallery.prototype.get(id) in the WASM glue (src/lib/wasm/index.ts) when builtinTemplates.find(t => t.id === id) returns undefined. The gallery is a fixed in-binary list of templates; get() assumes the caller already knows a valid id (typically obtained from list()/search()). loadRvf(id) calls get() first, so it surfaces the same error for RVF export.","triggerScenarios":"Calling gallery.get(id) with an id that is not in builtinTemplates: a typo, an id from a different/older build, or an id returned by a search that matched nothing.","commonSituations":"Persisting an activeTemplateId that was later renamed/removed from the builtins; hardcoding an id in a test; a version skew where the worker gallery (wasm.worker.ts) has different builtins than this glue.","solutions":["Call gallery.list() (or search()) and confirm the id is present before calling get().","If the id was persisted, validate it against the current builtin list on load and clear it if missing (the wasmMcp store already does this for activeTemplateId).","Rebuild so the glue and the WASM binary ship the same template set."],"exampleFix":"// before\nconst t = gallery.get(maybeStaleId); // throws\n// after\nconst ids = new Set(gallery.list().map((t) => t.id));\nif (!ids.has(maybeStaleId)) throw new Error(`unknown template ${maybeStaleId}; available: ${[...ids].join(\",\")}`);\nconst t = gallery.get(maybeStaleId);","handlingStrategy":"validation","validationCode":"const ids = new Set(gallery.list().map((t) => t.id));\nif (!ids.has(id)) {\n  throw new Error(`unknown template ${id}; available: ${[...ids].join(\", \")}`);\n}\nreturn gallery.get(id);","typeGuard":"function isKnownTemplate(gallery: { list: () => { id: string }[] }, id: string): boolean {\n  return gallery.list().some((t) => t.id === id);\n}","tryCatchPattern":"try {\n  return gallery.get(id);\n} catch (e) {\n  if (String((e as Error)?.message).startsWith(\"Template not found\")) return null;\n  throw e;\n}","preventionTips":["Validate persisted activeTemplateId against the current builtin list on load; clear if missing.","Source template ids from list()/search() results, never hardcode.","Rebuild glue + WASM together so the builtin set is consistent."],"tags":["wasm","template","gallery","validation"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}