{"record":{"id":"8e53259e20d60ce3","repo":"ruvnet/ruflo","slug":"pattern-not-found-patternid","errorCode":null,"errorMessage":"Pattern not found: ${patternId}","messagePattern":"Pattern not found: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/transfer/store/index.ts","lineNumber":155,"sourceCode":"   * Get pattern by ID\n   */\n  getPattern(patternId: string): PatternEntry | undefined {\n    if (!this.registry) {\n      throw new Error('Store not initialized. Call initialize() first.');\n    }\n    return this.registry.patterns.find(p => p.id === patternId);\n  }\n\n  /**\n   * Download pattern\n   */\n  async download(\n    patternId: string,\n    options: DownloadOptions = {}\n  ): Promise<DownloadResult> {\n    const pattern = this.getPattern(patternId);\n    if (!pattern) {\n      throw new Error(`Pattern not found: ${patternId}`);\n    }\n    if (!this.downloader) {\n      throw new Error('Store not initialized. Call initialize() first.');\n    }\n    return this.downloader.downloadPattern(pattern, options);\n  }\n\n  /**\n   * Publish pattern\n   */\n  async publish(\n    cfp: CFPFormat,\n    options: PublishOptions\n  ): Promise<PublishResult> {\n    if (!this.publisher) {\n      throw new Error('Store not initialized. Call initialize() first.');\n    }\n    return this.publisher.publishPattern(cfp, options);","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/transfer/store/index.ts#L137-L173","documentation":"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.","triggerScenarios":"(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.","commonSituations":"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.","solutions":["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.","Refresh the registry: `await store.initialize()` again to pull the latest pattern list before the lookup.","Check that the store's config/registryName targets the registry the pattern actually lives in.","If the pattern was removed upstream, search for a replacement pattern providing the same capability."],"exampleFix":"// before\nawait store.download('cfp-deadbeef'); // throws: Pattern not found: cfp-deadbeef\n\n// after\nawait store.initialize(); // refresh registry\nconst hit = store.search({ query: 'auth' }).patterns[0];\nif (!hit) throw new Error('no matching pattern in this registry');\nawait store.download(hit.id);","handlingStrategy":"validation","validationCode":"await store.initialize(); // ensure fresh registry\nconst pattern = store.getPattern(patternId);\nif (!pattern) {\n  // surface available candidates instead of a raw crash\n  const near = store.search({ query: patternId }).patterns.slice(0, 5).map(p => p.id);\n  throw new Error(`pattern ${patternId} not found; closest: ${near.join(', ') || 'none'}`);\n}\nawait store.download(patternId, options);","typeGuard":null,"tryCatchPattern":"try {\n  await store.download(patternId, options);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Pattern not found:')) {\n    await store.initialize();                       // refresh registry, IDs may have changed\n    await store.download(patternId, options);       // one retry with fresh data\n  } else {\n    throw err;\n  }\n}","preventionTips":["Never hardcode pattern IDs without a fallback — resolve them via search() at runtime","Re-initialize before lookups in long-running processes so the ID set stays current","Verify which registry the store targets (config/registryName) before blaming the ID","Log available IDs when a lookup misses; makes stale-registry diagnosis obvious"],"tags":["pattern-store","not-found","registry","lookup"],"backgroundTag":"resource-not-found","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}