{"record":{"id":"cc57457acf8f9fc3","repo":"affaan-m/ECC","slug":"unknown-session-adapter-id","errorCode":null,"errorMessage":"Unknown session adapter: ${id}","messagePattern":"Unknown session adapter: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/session-adapters/registry.js","lineNumber":107,"sourceCode":"      context: nextContext\n    };\n  }\n\n  return {\n    target: value,\n    context: nextContext\n  };\n}\n\nfunction createAdapterRegistry(options = {}) {\n  const adapters = options.adapters || createDefaultAdapters(options);\n\n  return {\n    adapters,\n    getAdapter(id) {\n      const adapter = adapters.find(candidate => candidate.id === id);\n      if (!adapter) {\n        throw new Error(`Unknown session adapter: ${id}`);\n      }\n\n      return adapter;\n    },\n    listAdapters() {\n      return adapters.map(adapter => ({\n        id: adapter.id,\n        description: adapter.description || '',\n        targetTypes: Array.isArray(adapter.targetTypes) ? [...adapter.targetTypes] : []\n      }));\n    },\n    select(target, context = {}) {\n      const normalized = normalizeStructuredTarget(target, context);\n      const adapter = normalized.context.adapterId\n        ? this.getAdapter(normalized.context.adapterId)\n        : adapters.find(candidate => candidate.canOpen(normalized.target, normalized.context));\n      if (!adapter) {\n        throw new Error(`No session adapter matched target: ${target}`);","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/session-adapters/registry.js#L89-L125","documentation":"getAdapter looks up an adapter by its exact id inside the registry's adapter list and throws when no registered adapter has that id. It is the registry's fail-fast guard: any caller resolving an adapterId (e.g. from a normalized structured target's context) must use a currently registered adapter id.","triggerScenarios":"Calling registry.getAdapter('unknown-id'); or a structured target carrying adapterId: 'codex' when no codex adapter was registered (createSessionAdapters called with a subset of adapters); or TARGET_TYPE_TO_ADAPTER_ID mapping a type to an adapter id that was not included in the adapters list.","commonSituations":"Typo in the adapter id ('claude-code' vs 'claude'); custom registry constructed with a restricted adapter list while old persisted targets still reference removed adapter ids; upgrading the library where an adapter was renamed or deleted but stored session targets keep the old id.","solutions":["Log/inspect the available ids with registry.listAdapters() and correct the id string to a listed adapter id.","If using a custom adapters array, register the missing adapter (e.g. include the claude adapter factory) so the referenced id exists.","If the id comes from persisted config/targets, migrate those records to the new adapter id after an upgrade or rename.","Wrap calls in try-catch and fall back to adapter auto-selection by omitting adapterId so canOpen() matching picks an adapter."],"exampleFix":"// before\nconst adapter = registry.getAdapter('claude-code'); // typo\n\n// after\nconst ids = registry.listAdapters().map(a => a.id);\nconst adapter = registry.getAdapter(ids.includes('claude-code') ? 'claude-code' : 'claude');","handlingStrategy":"try-catch","validationCode":"const known = new Set(registry.listAdapters().map(a => a.id));\nif (!known.has(id)) console.warn(`id ${id} not registered; available: ${[...known].join(', ')}`);","typeGuard":null,"tryCatchPattern":"try {\n  adapter = registry.getAdapter(id);\n} catch (err) {\n  if (String(err.message).startsWith('Unknown session adapter')) {\n    adapter = registry.listAdapters()[0]; // or prompt user\n  } else throw err;\n}","preventionTips":["Call listAdapters() and log available ids whenever an adapter id comes from config or persisted data.","Centralize adapter id constants in a shared module instead of repeating raw strings.","On library upgrades, grep persisted targets/config for old adapter ids and migrate them."],"tags":["registry","adapter-lookup","session-adapters"],"backgroundTag":"resource-not-found","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}