affaan-m/ECC · error · Error

Codex rollout session not found

Error message

Codex rollout session not found: ${explicitTarget}

What it means

resolveRolloutPath throws this when an explicit Codex rollout identifier was given but findRolloutById(sessionsDir, explicitTarget) matched no rollout file, and the target is not directly a rollout file path either (it fell through to this throw after the id lookup).

Solutions

  1. Search the sessions directory for rollout files and copy the exact id from a filename.
  2. Pass the full path to the rollout .jsonl file instead of an id.
  3. Verify the sessions dir resolution (options/env) matches where Codex actually writes.
  4. Check whitespace/case in the id; trim before calling.
  5. Re-run Codex to regenerate a rollout if the history was deleted.

Example fix

// before
resolve('rollout-2026-09-14T10-00-00'); // id guess -> throws
// after
const files = findRolloutFiles(sessionsDir);
if (!files.some(f => f.includes(id))) {
  throw new Error(`Rollout '${id}' not found. Available: ${files.map(f => path.basename(f)).join(', ')}`);
}
resolve(id);
Defensive patterns

Strategy: validation

Validate before calling

const files = findRolloutFiles(sessionsDir);
if (!files.some(f => path.basename(f).includes(rolloutId))) throw new Error(`Rollout '${rolloutId}' not found in ${sessionsDir}`);

Type guard

function isKnownRolloutId(id, files) { return typeof id === 'string' && id.trim().length > 0 && files.some(f => path.basename(f).includes(id)); }

Try / catch

try { return adapter.resolveRolloutPath(id); } catch (e) { if (/^Codex rollout session not found:/.test(e.message)) throw new Error(`Use an id from the sessions dir; '${id}' absent`); throw e; }

Prevention

When it happens

Trigger: resolveRolloutPath called with explicitTarget set to a rollout id/session token that has no matching file under the sessions dir; id truncated, from another machine, or the rollout was deleted.

Common situations: Copying a rollout id from Codex UI/logs on a different machine; retention pruning removed the referenced rollout; id case mismatch; pointing at a non-rollout file that isCodexRolloutFileTarget rejects.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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

Appendix: source

Thrown at scripts/lib/session-adapters/codex-worktree.js:126

      const latest = findLatestRollout(sessionsDir);
      if (!latest) {
        throw new Error('No Codex rollout sessions found');
      }

      return { rolloutPath: latest, sourceTarget: { type: 'codex-worktree', value: 'latest' } };
    }

    const absoluteExplicit = path.resolve(cwd, explicitTarget);
    if (fs.existsSync(absoluteExplicit) && isRolloutFile(absoluteExplicit)) {
      return { rolloutPath: absoluteExplicit, sourceTarget: { type: 'codex-rollout-file', value: absoluteExplicit } };
    }

    const byId = findRolloutById(sessionsDir, explicitTarget);
    if (byId) {
      return { rolloutPath: byId, sourceTarget: { type: 'codex-worktree', value: explicitTarget } };
    }

    throw new Error(`Codex rollout session not found: ${explicitTarget}`);
  }

  if (isCodexRolloutFileTarget(target, cwd)) {
    const absoluteTarget = path.resolve(cwd, target);
    return { rolloutPath: absoluteTarget, sourceTarget: { type: 'codex-rollout-file', value: absoluteTarget } };
  }

  throw new Error(`Unsupported Codex session target: ${target}`);
}

function readJsonLines(filePath) {
  const raw = fs.readFileSync(filePath, 'utf8');
  const records = [];

  for (const line of raw.split('\n')) {
    const trimmed = line.trim();
    if (trimmed.length === 0) {
      continue;

View on GitHub (pinned to 8321021c54)