affaan-m/ECC · error · Error

No Claude session history found

Error message

No Claude session history found

What it means

resolveSessionRecord in the Claude history adapter throws this when the session target resolves to 'latest' but sessionManager.getAllSessions({limit:1}) returns no sessions. It means the Claude session store (~/.claude/projects history files) is empty or unreadable, so there is no 'most recent' session to resolve.

Solutions

  1. Run Claude Code once in this project to generate at least one session, then retry.
  2. Verify the sessions directory (CLAUDE_CONFIG_DIR / history path) that sessionManager reads actually contains session files.
  3. Pass an explicit session id/filename or a session file path as target instead of 'latest'.
  4. Check cwd: session lookup is scoped to the project; run from the correct repository root.
  5. List available sessions via sessionManager.getAllSessions() and pick a valid one.

Example fix

// before
const { session } = adapter.resolveSessionRecord('latest'); // throws when history empty
// after
const sessions = sessionManager.getAllSessions({ limit: 1 }).sessions;
if (sessions.length === 0) throw new Error('Run `claude` in this project first; no session history exists.');
const { session } = adapter.resolveSessionRecord('latest');
Defensive patterns

Strategy: fallback

Validate before calling

const latest = sessionManager.getAllSessions({ limit: 1 }).sessions;
if (!latest || latest.length === 0) throw new Error('No Claude session history; run claude in this project first');

Type guard

function hasLatest(sessions) { return Array.isArray(sessions) && sessions.length > 0; }

Try / catch

try { return adapter.resolveSessionRecord('latest'); } catch (e) { if (e.message === 'No Claude session history found') return null; throw e; }

Prevention

When it happens

Trigger: Calling resolveSessionRecord (directly or via the adapter factory in createClaudeHistoryAdapter) with parseClaudeTarget(target) === 'latest' while getAllSessions({limit:1}).sessions is an empty array — e.g. no Claude sessions exist on disk for the current project or the sessions directory is misconfigured.

Common situations: Fresh machine or CI container where Claude has never been used in this project; CLAUDE_CONFIG_DIR pointed at an empty/wrong directory; project path changed so session filenames no longer match the current cwd; history files pruned by a cleanup script.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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

Appendix: source

Thrown at scripts/lib/session-adapters/claude-history.js:64

    ...parsed,
    sessionPath,
    content,
    metadata: sessionManager.parseSessionMetadata(content),
    stats: sessionManager.getSessionStats(content || ''),
    size: stats.size,
    modifiedTime: stats.mtime,
    createdTime: stats.birthtime || stats.ctime
  };
}

function resolveSessionRecord(target, cwd) {
  const explicitTarget = parseClaudeTarget(target);

  if (explicitTarget) {
    if (explicitTarget === 'latest') {
      const [latest] = sessionManager.getAllSessions({ limit: 1 }).sessions;
      if (!latest) {
        throw new Error('No Claude session history found');
      }

      return {
        session: sessionManager.getSessionById(latest.filename, true),
        sourceTarget: {
          type: 'claude-history',
          value: 'latest'
        }
      };
    }

    const alias = sessionAliases.resolveAlias(explicitTarget);
    if (alias) {
      return {
        session: hydrateSessionFromPath(alias.sessionPath),
        sourceTarget: {
          type: 'claude-alias',
          value: explicitTarget

View on GitHub (pinned to 8321021c54)