{"record":{"id":"23ced9fa04380197","repo":"affaan-m/ECC","slug":"codex-rollout-session-not-found-explicittarget","errorCode":null,"errorMessage":"Codex rollout session not found: ${explicitTarget}","messagePattern":"Codex rollout session not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/session-adapters/codex-worktree.js","lineNumber":126,"sourceCode":"      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\n  if (isCodexRolloutFileTarget(target, cwd)) {\n    const absoluteTarget = path.resolve(cwd, target);\n    return { rolloutPath: absoluteTarget, sourceTarget: { type: 'codex-rollout-file', value: absoluteTarget } };\n  }\n\n  throw new Error(`Unsupported Codex session target: ${target}`);\n}\n\nfunction readJsonLines(filePath) {\n  const raw = fs.readFileSync(filePath, 'utf8');\n  const records = [];\n\n  for (const line of raw.split('\\n')) {\n    const trimmed = line.trim();\n    if (trimmed.length === 0) {\n      continue;","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/session-adapters/codex-worktree.js#L108-L144","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["List rollouts to confirm the id: listRolloutFiles(sessionsDir) and inspect basenames.","If the rollout exists elsewhere, point CODEX_HOME or the worktree root at that location before resolving.","Pass the absolute path to the rollout file as the target to hit the absoluteExplicit branch.","Verify the id format matches what findRolloutById searches for (basename.includes(sessionId))."],"exampleFix":"// before\nadapter.open('codex:abc', { cwd }); // not found\n\n// after\nconst files = listRolloutFiles(sessionsDir);\nadapter.open(`codex:${path.basename(files[0])}`, { cwd });\n// or\nadapter.open('/abs/path/to/rollout.jsonl', { cwd });","handlingStrategy":"validation","validationCode":"const byId = findRolloutById(sessionsDir, explicitTarget);\nconst abs = path.resolve(cwd, explicitTarget);\nif (!byId && !(fs.existsSync(abs) && isRolloutFile(abs))) {\n  const known = listRolloutFiles(sessionsDir).map(f => path.basename(f)).join(', ');\n  throw new Error(`Codex rollout not found: ${explicitTarget}. Known: ${known}`);\n}","typeGuard":"function codexTargetExists(target, cwd, sessionsDir) {\n  const abs = path.resolve(cwd, target);\n  return (fs.existsSync(abs) && isRolloutFile(abs))\n    || Boolean(findRolloutById(sessionsDir, target));\n}","tryCatchPattern":"try { return resolveRolloutPath(target, cwd, options, context); }\ncatch (err) {\n  if (err.message.startsWith('Codex rollout session not found:')) {\n    const list = listRolloutFiles(sessionsDir).map(f => path.basename(f));\n    throw new Error(`${err.message}. Known rollouts: ${list.join(', ')}`);\n  }\n  throw err;\n}","preventionTips":["List rollouts before resolving a bare id.","Sync rollout files into the local sessions dir for cross-machine runs.","Pass an absolute path when the id may be ambiguous."],"tags":["codex-worktree","session-resolution","not-found"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}