ruvnet/ruflo · error · Error

Pattern not found: ${patternId}

Error message

Pattern not found: ${patternId}

What it means

PatternStore#download() resolves patternId against the loaded registry's patterns array and throws when no entry matches. The registry comes from remote discovery, so the ID set you can download is exactly what the last successful initialize() fetched — an ID valid in another registry, an older snapshot, or after upstream removal will not resolve.

Source

Thrown at v3/@claude-flow/cli/src/transfer/store/index.ts:155

   * Get pattern by ID
   */
  getPattern(patternId: string): PatternEntry | undefined {
    if (!this.registry) {
      throw new Error('Store not initialized. Call initialize() first.');
    }
    return this.registry.patterns.find(p => p.id === patternId);
  }

  /**
   * Download pattern
   */
  async download(
    patternId: string,
    options: DownloadOptions = {}
  ): Promise<DownloadResult> {
    const pattern = this.getPattern(patternId);
    if (!pattern) {
      throw new Error(`Pattern not found: ${patternId}`);
    }
    if (!this.downloader) {
      throw new Error('Store not initialized. Call initialize() first.');
    }
    return this.downloader.downloadPattern(pattern, options);
  }

  /**
   * Publish pattern
   */
  async publish(
    cfp: CFPFormat,
    options: PublishOptions
  ): Promise<PublishResult> {
    if (!this.publisher) {
      throw new Error('Store not initialized. Call initialize() first.');
    }
    return this.publisher.publishPattern(cfp, options);

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Confirm the ID exists before downloading: `store.getPattern(id)` returns undefined (it throws only when the store itself is uninitialized), or use `store.search({ query })` to discover the current exact id.
  2. Refresh the registry: `await store.initialize()` again to pull the latest pattern list before the lookup.
  3. Check that the store's config/registryName targets the registry the pattern actually lives in.
  4. If the pattern was removed upstream, search for a replacement pattern providing the same capability.

Example fix

// before
await store.download('cfp-deadbeef'); // throws: Pattern not found: cfp-deadbeef

// after
await store.initialize(); // refresh registry
const hit = store.search({ query: 'auth' }).patterns[0];
if (!hit) throw new Error('no matching pattern in this registry');
await store.download(hit.id);
Defensive patterns

Strategy: validation

Validate before calling

await store.initialize(); // ensure fresh registry
const pattern = store.getPattern(patternId);
if (!pattern) {
  // surface available candidates instead of a raw crash
  const near = store.search({ query: patternId }).patterns.slice(0, 5).map(p => p.id);
  throw new Error(`pattern ${patternId} not found; closest: ${near.join(', ') || 'none'}`);
}
await store.download(patternId, options);

Try / catch

try {
  await store.download(patternId, options);
} catch (err) {
  if (err instanceof Error && err.message.startsWith('Pattern not found:')) {
    await store.initialize();                       // refresh registry, IDs may have changed
    await store.download(patternId, options);       // one retry with fresh data
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: (1) Typo or case mismatch in the patternId string; (2) using an ID copied from an older registry snapshot after the pattern was unpublished; (3) initializing against a different known registry than the one the ID came from; (4) calling download() on a stale store after the upstream registry changed.

Common situations: Hardcoded pattern IDs in scripts that break when the registry evolves; documentation examples referencing retired patterns; switching registryName/config between environments so IDs no longer match.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/8e53259e20d60ce3. Report an issue: GitHub.