ruvnet/ruflo · error · Error

Gallery template not found: ${templateId}

Error message

Gallery template not found: ${templateId}

What it means

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.

Source

Thrown at v3/@claude-flow/cli/src/ruvector/agent-wasm.ts:420

/**
 * Get a gallery template by id.
 * Wraps in try/catch because WasmGallery.get() panics on unknown IDs in v0.1.0.
 */
export async function getGalleryTemplate(id: string): Promise<GalleryTemplateDetail | null> {
  const gallery = await getGallery();
  try {
    return gallery.get(id) ?? null;
  } catch {
    return null;
  }
}

/**
 * Create an agent from a gallery template.
 */
export async function createAgentFromTemplate(templateId: string): Promise<WasmAgentInfo> {
  const template = await getGalleryTemplate(templateId);
  if (!template) throw new Error(`Gallery template not found: ${templateId}`);

  const systemPrompt = template.prompts?.[0]?.system_prompt;
  return createWasmAgent({
    instructions: systemPrompt ?? `You are a ${template.name}.`,
    model: undefined, // Use default
  });
}

// ── RVF Container Operations ─────────────────────────────────

export interface McpToolDescriptor {
  name: string;
  description: string;
  input_schema: unknown;
  group?: string;
}

/**

View on GitHub (pinned to 6b01dc5a68)

Solutions

  1. Call listGalleryTemplates() (or searchGalleryTemplates(q)) first and confirm the ID exists; surface the list of valid IDs to the caller.
  2. If using a custom template, ensure galleryAddCustom / galleryImportCustom succeeded before referencing it.
  3. Treat a null result from getGalleryTemplate as authoritative — do not retry the WASM call directly (it may panic).

Example fix

// before
const info = await createAgentFromTemplate('coder-pro');

// after — validate against the live gallery
const valid = (await listGalleryTemplates()).map(t => t.id);
if (!valid.includes('coder-pro')) {
  throw new Error(`unknown template 'coder-pro'. available: ${valid.join(', ')}`);
}
const info = await createAgentFromTemplate('coder-pro');
Defensive patterns

Strategy: validation

Validate before calling

async function assertTemplateExists(templateId: string): Promise<void> {
  const valid = (await listGalleryTemplates()).map(t => t.id);
  if (!valid.includes(templateId)) {
    throw new Error(`template '${templateId}' not in gallery. available: ${valid.join(', ')}`);
  }
}

await assertTemplateExists('coder-pro');
const info = await createAgentFromTemplate('coder-pro');

Type guard

async function templateExists(id: string): Promise<boolean> {
  return (await getGalleryTemplate(id)) !== null;
}

Try / catch

try {
  return await createAgentFromTemplate(id);
} catch (e) {
  if (/Gallery template not found/.test(String(e))) {
    const valid = (await listGalleryTemplates()).map(t => t.id);
    throw new Error(`${e.message}. available: ${valid.join(', ')}`);
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of ruvnet/ruflo@6b01dc5a68 (2026-08-12). Data as JSON: /api/errors/56f4a488b08c9ab0. Report an issue: GitHub.