{"record":{"id":"1c809af25ee191cb","repo":"affaan-m/ECC","slug":"no-codex-rollout-sessions-found","errorCode":null,"errorMessage":"No Codex rollout sessions found","messagePattern":"No Codex rollout sessions found","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/session-adapters/codex-worktree.js","lineNumber":110,"sourceCode":"  return files\n    .map(filePath => ({ filePath, mtimeMs: fs.statSync(filePath).mtimeMs }))\n    .sort((a, b) => b.mtimeMs - a.mtimeMs)[0].filePath;\n}\n\nfunction findRolloutById(sessionsDir, sessionId) {\n  return listRolloutFiles(sessionsDir)\n    .find(filePath => path.basename(filePath).includes(sessionId)) || null;\n}\n\nfunction resolveRolloutPath(target, cwd, options, context) {\n  const explicitTarget = parseCodexTarget(target);\n  const sessionsDir = resolveSessionsDir(options, context);\n\n  if (explicitTarget) {\n    if (explicitTarget === 'latest') {\n      const latest = findLatestRollout(sessionsDir);\n      if (!latest) {\n        throw new Error('No Codex rollout sessions found');\n      }\n\n      return { rolloutPath: latest, sourceTarget: { type: 'codex-worktree', value: 'latest' } };\n    }\n\n    const absoluteExplicit = path.resolve(cwd, explicitTarget);\n    if (fs.existsSync(absoluteExplicit) && isRolloutFile(absoluteExplicit)) {\n      return { rolloutPath: absoluteExplicit, sourceTarget: { type: 'codex-rollout-file', value: absoluteExplicit } };\n    }\n\n    const byId = findRolloutById(sessionsDir, explicitTarget);\n    if (byId) {\n      return { rolloutPath: byId, sourceTarget: { type: 'codex-worktree', value: explicitTarget } };\n    }\n\n    throw new Error(`Codex rollout session not found: ${explicitTarget}`);\n  }\n","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/session-adapters/codex-worktree.js#L92-L128","documentation":"resolveRolloutPath in the Codex adapter throws this when target 'latest' is requested but findLatestRollout(sessionsDir) finds no rollout files under the Codex sessions directory. There is no most-recent rollout to return.","triggerScenarios":"resolveRolloutPath called with explicitTarget === 'latest' while the resolved sessions dir (~/.codex/sessions or options-overridden dir) contains no rollout files or the dir does not exist.","commonSituations":"Codex never run on this machine/container; CODEX_HOME pointing at an empty directory; rollout files pruned by retention cleanup; running in a repo where Codex sessions are stored per-cwd and this project has none.","solutions":["Run Codex at least once to generate a rollout under the sessions directory.","Verify resolveSessionsDir options/env (e.g. CODEX_HOME) point at the directory containing rollout .jsonl files.","Pass an explicit rollout id or rollout file path instead of 'latest'.","Run from the correct working directory if lookup is cwd-scoped.","Check file permissions on the sessions directory (root-run CI can hide user dirs)."],"exampleFix":"// before\nconst { rolloutPath } = codexAdapter.resolveRolloutPath('latest'); // throws when empty\n// after\nconst dir = path.join(os.homedir(), '.codex', 'sessions');\nif (!fs.existsSync(dir) || fs.readdirSync(dir, { recursive: true }).filter(f => f.endsWith('.jsonl')).length === 0) {\n  throw new Error('No Codex rollouts found; run `codex` first or set CODEX_HOME correctly');\n}","handlingStrategy":"fallback","validationCode":"const dir = resolveSessionsDir();\nif (!fs.existsSync(dir) || findRolloutFiles(dir).length === 0) throw new Error('No Codex rollouts; run codex or fix sessions dir');","typeGuard":"function hasRollouts(dir) { return fs.existsSync(dir) && fs.readdirSync(dir, { recursive: true }).some(f => String(f).endsWith('.jsonl')); }","tryCatchPattern":"try { return adapter.resolveRolloutPath('latest'); } catch (e) { if (e.message === 'No Codex rollout sessions found') return null; throw e; }","preventionTips":["Run Codex once to seed rollouts before relying on 'latest'","Pin CODEX_HOME / sessions dir in CI","Prefer explicit rollout paths in automation","Verify permissions when running as different users"],"tags":["session","codex","rollout","not-found"],"backgroundTag":"empty-result-set","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}