{"record":{"id":"8bc6bce26a0852ec","repo":"affaan-m/ECC","slug":"unsupported-codex-session-target-target","errorCode":null,"errorMessage":"Unsupported Codex session target: ${target}","messagePattern":"Unsupported Codex session target: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/session-adapters/codex-worktree.js","lineNumber":134,"sourceCode":"    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;\n    }\n\n    try {\n      records.push(JSON.parse(trimmed));\n    } catch {\n      // Rollout logs are append-only; skip partial/corrupt trailing lines.\n    }\n  }","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/session-adapters/codex-worktree.js#L116-L152","documentation":"Terminal guard of resolveRolloutPath: the target did not parse as 'latest', a rollout id, or a Codex rollout file path, so the adapter cannot resolve it. It is the Codex analogue of the unsupported-target error.","triggerScenarios":"resolveRolloutPath called with strings like '', a directory path, a Claude/OpenCode session path, or any value isCodexRolloutFileTarget(target, cwd) rejects after explicitTarget is null and no id lookup was possible.","commonSituations":"Passing an OpenCode or Claude session file to the Codex adapter; empty env/config value; path pointing at a directory rather than a rollout file; wrong extension (isCodexRolloutFileTarget likely requires .jsonl).","solutions":["Supply 'latest', a valid rollout id from the sessions dir, or an existing rollout .jsonl file path.","Confirm the file extension/format matches what isCodexRolloutFileTarget accepts.","Trim the value and log it to catch empty or misquoted input.","Route the call to the correct adapter (claude-history / opencode) if the target belongs to another harness.","Check cwd resolution: relative paths are resolved against cwd."],"exampleFix":"// before\nresolve('./sessions'); // directory, not a rollout file -> throws\n// after\nconst t = target.trim();\nif (t !== 'latest' && !(fs.existsSync(t) && fs.statSync(t).isFile() && t.endsWith('.jsonl'))) {\n  throw new Error(`Unsupported Codex target '${t}': use 'latest', a rollout id, or a .jsonl rollout path`);\n}\nresolve(t);","handlingStrategy":"validation","validationCode":"if (target !== 'latest' && !(typeof target === 'string' && fs.existsSync(target) && fs.statSync(target).isFile() && target.endsWith('.jsonl'))) throw new Error(`Invalid Codex target: '${target}'`);","typeGuard":"function isValidCodexTarget(t) { return t === 'latest' || (typeof t === 'string' && t.endsWith('.jsonl') && fs.existsSync(t) && fs.statSync(t).isFile()); }","tryCatchPattern":"try { return adapter.resolveRolloutPath(target); } catch (e) { if (/^Unsupported Codex session target:/.test(e.message)) console.error(`Codex target must be 'latest', a rollout id, or a .jsonl path; got '${target}'`); throw e; }","preventionTips":["Validate target shape before dispatching to the adapter","Never pass directories as targets","Match target type to the correct harness adapter","Trim values coming from env/config"],"tags":["session","codex","invalid-argument"],"backgroundTag":"invalid-argument-value","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"}