{"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":"exception","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/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/session-adapters/codex-worktree.js#L92-L128","documentation":"resolveRolloutPath was called with target 'latest' (or codex:latest) but findLatestRollout(sessionsDir) returned null. The Codex worktree adapter found no rollout files in the resolved Codex sessions directory.","triggerScenarios":"Requesting the latest Codex rollout on a machine where Codex has never run, or where the sessions directory is set to an empty/non-existent path. CODEX_HOME or the worktree root is overridden so resolveSessionsDir points elsewhere.","commonSituations":"Fresh environment with no Codex rollouts. CI container with isolated HOME lacking ~/.codex. Worktree root passed via context does not contain a sessions subdir. Codex CLI version writes rollouts to a different path.","solutions":["Run Codex at least once so it creates a rollout file, then retry 'latest'.","Verify the sessions directory resolveSessionsDir points at exists and contains *.rollout* (or listRolloutFiles-matching) files.","If CODEX_HOME or the worktree root is overridden, set it to the directory that actually holds the rollouts.","Pass an explicit rollout id or absolute path instead of 'latest'."],"exampleFix":"// before\nadapter.open('codex:latest', { cwd });\n\n// after\nadapter.open('codex:<known-session-id>', { cwd });\n// or run `codex` once to seed the sessions directory, then retry 'latest'","handlingStrategy":"validation","validationCode":"const latest = findLatestRollout(sessionsDir);\nif (!latest) {\n  throw new Error(`No Codex rollouts in ${sessionsDir}; run 'codex' first or pass an explicit rollout id.`);\n}","typeGuard":"function hasAnyCodexRollout(sessionsDir) {\n  return listRolloutFiles(sessionsDir).length > 0;\n}","tryCatchPattern":"try { return resolveRolloutPath('latest', cwd, options, context); }\ncatch (err) {\n  if (err.message === 'No Codex rollout sessions found') {\n    throw new Error('No Codex rollouts found. Pass an explicit rollout id or .rollout path.');\n  }\n  throw err;\n}","preventionTips":["Run Codex once before scripting against 'latest'.","Confirm CODEX_HOME and the worktree root point at the dir holding rollouts.","Prefer explicit ids in automation."],"tags":["codex-worktree","session-resolution","empty-state"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}