affaan-m/ECC · error · Error

No session adapter matched target

Error message

No session adapter matched target: ${target}

What it means

select() normalizes the target, then resolves an adapter either via the normalized adapterId or by asking each registered adapter's canOpen() whether it can handle the target. If no adapterId is set and no adapter's canOpen() accepts the target, no match exists and the registry throws. This means the target shape/value was not recognized by any available adapter.

Solutions

  1. Verify the target string matches a format one of the adapters supports (run registry.listAdapters() and check each adapter's id/type).
  2. Pass an explicit structured target { type, value } whose type maps to an existing adapter via TARGET_TYPE_TO_ADAPTER_ID.
  3. Ensure the adapter that should handle the target is included in the adapters array passed to the registry constructor.
  4. Wrap select in try-catch and surface the supported target formats in the user-facing message.

Example fix

// before
registry.select('~/weird/nonexistent-session.json');

// after
const target = fs.existsSync('~/weird/nonexistent-session.json')
  ? '~/weird/nonexistent-session.json'
  : { type: 'claude', value: 'session-abc' };
registry.select(target);
Defensive patterns

Strategy: try-catch

Validate before calling

const exists = registry.listAdapters().some(a => a.canOpen?.(target, {}));
if (!exists && typeof target !== 'object') console.warn('no adapter will accept this target');

Try / catch

try {
  adapter = registry.select(target);
} catch (err) {
  if (err.message.startsWith('No session adapter matched')) {
    throw new Error(`Unsupported target '${target}'. Supported: ${registry.listAdapters().map(a => a.id).join(', ')}`);
  }
  throw err;
}

Prevention

When it happens

Trigger: registry.select('some-freeform-target') where every adapter's canOpen() returns false (e.g. the string is neither a session-id pattern nor a known path); a structured target with adapterId null whose type has no TARGET_TYPE_TO_ADAPTER_ID mapping; calling select on an empty/unrecognizable value like '' or an unknown URI scheme.

Common situations: Pasting a target from another tool's session format (e.g. a Cursor path into a registry without the cursor adapter); typos in the target string; environment where expected adapter registration was skipped so canOpen matching is narrower than expected.

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 affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/22c7bfa47f99d69d. Report an issue: GitHub.

Appendix: source

Thrown at scripts/lib/session-adapters/registry.js:125

        throw new Error(`Unknown session adapter: ${id}`);
      }

      return adapter;
    },
    listAdapters() {
      return adapters.map(adapter => ({
        id: adapter.id,
        description: adapter.description || '',
        targetTypes: Array.isArray(adapter.targetTypes) ? [...adapter.targetTypes] : []
      }));
    },
    select(target, context = {}) {
      const normalized = normalizeStructuredTarget(target, context);
      const adapter = normalized.context.adapterId
        ? this.getAdapter(normalized.context.adapterId)
        : adapters.find(candidate => candidate.canOpen(normalized.target, normalized.context));
      if (!adapter) {
        throw new Error(`No session adapter matched target: ${target}`);
      }

      return adapter;
    },
    open(target, context = {}) {
      const normalized = normalizeStructuredTarget(target, context);
      const adapter = this.select(normalized.target, normalized.context);
      return adapter.open(normalized.target, normalized.context);
    }
  };
}

function inspectSessionTarget(target, options = {}) {
  const registry = createAdapterRegistry(options);
  return registry.open(target, options).getSnapshot();
}

module.exports = {

View on GitHub (pinned to 8321021c54)