affaan-m/ECC · error

Session not found

Error message

Session not found: ${options.sessionId}

What it means

main in scripts/sessions-cli.js looks up the session detail via store.getSessionDetail(options.sessionId) and throws when the store returns no payload. This means no session record matches the given id.

Solutions

  1. List available sessions first (e.g. `node scripts/sessions-cli.js --help` or the list command) and copy the exact id.
  2. Verify the session store path/data exists for the current working directory.
  3. Re-run with the full, untruncated session id.

Example fix

// before
node scripts/sessions-cli.js abc12
// after
node scripts/sessions-cli.js abc123e4-d56f-7890-abcd-ef1234567890
Defensive patterns

Strategy: try-catch

Validate before calling

const exists = store.listSessions().some(s => s.id === sessionId);
if (!exists) { console.error(`Session ${sessionId} not in store`); process.exit(2); }

Type guard

const sessionExists = (id, sessions) => sessions.some(s => s && s.id === id);

Try / catch

try { const payload = store.getSessionDetail(id); if (!payload) throw new Error(`Session not found: ${id}`); } catch (e) { console.error(e.message + ' — list sessions to get a valid id'); process.exit(2); }

Prevention

When it happens

Trigger: Running `node scripts/sessions-cli.js <id>` with an id that is misspelled, was deleted/pruned from the session store, or was created by a different store directory.

Common situations: Copy-pasting a truncated id, referencing a session from an old repo clone where the store isn't present, sessions cleaned up by a retention task.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/1e7447e13b36f895. Report an issue: GitHub.

Appendix: source

Thrown at scripts/sessions-cli.js:153

    store = await createStateStore({
      dbPath: options.dbPath,
      homeDir: process.env.HOME || os.homedir(),
    });

    if (!options.sessionId) {
      const payload = store.listRecentSessions({ limit: options.limit });
      if (options.json) {
        console.log(JSON.stringify(payload, null, 2));
      } else {
        printSessionList(payload);
      }
      return;
    }

    const payload = store.getSessionDetail(options.sessionId);
    if (!payload) {
      throw new Error(`Session not found: ${options.sessionId}`);
    }

    if (options.json) {
      console.log(JSON.stringify(payload, null, 2));
    } else {
      printSessionDetail(payload);
    }
  } catch (error) {
    console.error(`Error: ${error.message}`);
    process.exit(1);
  } finally {
    if (store) {
      store.close();
    }
  }
}

if (require.main === module) {

View on GitHub (pinned to 8321021c54)