affaan-m/ECC · error · Error

Codex rollout session not found: ${explicitTarget}

Error message

Codex rollout session not found: ${explicitTarget}

What it means

resolveRolloutPath got an explicit target that is not 'latest', did not match an existing .rollout file on disk (absoluteExplicit check failed), and findRolloutById(sessionsDir, explicitTarget) returned null. The Codex adapter could not locate a rollout matching that id in the resolved sessions directory.

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 01e15490f0)

Solutions

  1. List rollouts to confirm the id: listRolloutFiles(sessionsDir) and inspect basenames.
  2. If the rollout exists elsewhere, point CODEX_HOME or the worktree root at that location before resolving.
  3. Pass the absolute path to the rollout file as the target to hit the absoluteExplicit branch.
  4. Verify the id format matches what findRolloutById searches for (basename.includes(sessionId)).

Example fix

// before
adapter.open('codex:abc', { cwd }); // not found

// after
const files = listRolloutFiles(sessionsDir);
adapter.open(`codex:${path.basename(files[0])}`, { cwd });
// or
adapter.open('/abs/path/to/rollout.jsonl', { cwd });
Defensive patterns

Strategy: validation

Validate before calling

const byId = findRolloutById(sessionsDir, explicitTarget);
const abs = path.resolve(cwd, explicitTarget);
if (!byId && !(fs.existsSync(abs) && isRolloutFile(abs))) {
  const known = listRolloutFiles(sessionsDir).map(f => path.basename(f)).join(', ');
  throw new Error(`Codex rollout not found: ${explicitTarget}. Known: ${known}`);
}

Type guard

function codexTargetExists(target, cwd, sessionsDir) {
  const abs = path.resolve(cwd, target);
  return (fs.existsSync(abs) && isRolloutFile(abs))
    || Boolean(findRolloutById(sessionsDir, target));
}

Try / catch

try { return resolveRolloutPath(target, cwd, options, context); }
catch (err) {
  if (err.message.startsWith('Codex rollout session not found:')) {
    const list = listRolloutFiles(sessionsDir).map(f => path.basename(f));
    throw new Error(`${err.message}. Known rollouts: ${list.join(', ')}`);
  }
  throw err;
}

Prevention

When it happens

Trigger: Passing a Codex session id that was never created, was deleted, or lives in a different sessions directory. Typo in the id. Pointing the adapter at the wrong worktree/CODEX_HOME so findRolloutById cannot see the file.

Common situations: Copy-paste error in a session id. Rollout pruned by Codex cleanup. Running on a different machine than where the rollout was created. Codex version stores rollouts under a different subdirectory.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/23ced9fa04380197. Report an issue: GitHub.