openai/codex-plugin-cc · error · Error
A Claude session source path is required.
Error message
A Claude session source path is required.
What it means
Thrown by importExternalAgentSession when options.sourcePath is falsy. After the Codex availability check passes, the function requires a concrete Claude transcript path to build the migration payload; an empty sourcePath means there is nothing to import.
Source
Thrown at plugins/codex/scripts/lib/codex.mjs:1064
threadId: turnState.threadId,
sourceThreadId,
turnId: turnState.turnId,
reviewText: turnState.reviewText,
reasoningSummary: turnState.reasoningSummary,
turn: turnState.finalTurn,
error: turnState.error,
stderr: cleanCodexStderr(client.stderr)
};
});
}
export async function importExternalAgentSession(cwd, options = {}) {
const availability = getCodexAvailability(cwd);
if (!availability.available) {
throw new Error("Codex CLI is not installed or is missing required runtime support. Install it with `npm install -g @openai/codex`, then rerun `/codex:setup`.");
}
if (!options.sourcePath) {
throw new Error("A Claude session source path is required.");
}
return withDirectAppServer(cwd, async (client) => {
emitProgress(options.onProgress, "Importing Claude session into Codex.", "transferring");
try {
await requestExternalAgentSessionImport(client, externalAgentSessionMigration(options.sourcePath, cwd));
} catch (error) {
if (error?.rpcCode === -32601) {
throw new Error(
"This Codex version does not support Claude session transfer. Update Codex with `npm install -g @openai/codex@latest`, then retry.",
{ cause: error }
);
}
throw error;
}
const threadId = importedThreadIdForSource(options.sourcePath);
if (!threadId) {
const stderr = cleanCodexStderr(client.stderr);View on GitHub (pinned to db52e28f4d)
Solutions
- Pass a non-empty sourcePath: importExternalAgentSession(cwd, { sourcePath: resolvedPath }).
- Run the path through resolveClaudeSessionPath first and use its return value as sourcePath.
- Validate options.sourcePath is a truthy string before calling.
- If sourcing from env, read CODEX_COMPANION_TRANSCRIPT_PATH and pass it through.
Example fix
// before
await importExternalAgentSession(cwd, {}) // throws
// after
const resolved = resolveClaudeSessionPath(cwd, { source: flagSource })
await importExternalAgentSession(cwd, { sourcePath: resolved }) Defensive patterns
Strategy: validation
Validate before calling
function requireSourcePath(options) {
if (!options?.sourcePath || typeof options.sourcePath !== 'string') {
throw new Error('sourcePath is required for import');
}
return options.sourcePath;
} Type guard
function hasSourcePath(o) {
return o != null && typeof o.sourcePath === 'string' && o.sourcePath.length > 0;
} Try / catch
null
Prevention
- Always derive sourcePath from resolveClaudeSessionPath before importing.
- Type-check options.sourcePath as a non-empty string in the caller.
- Fail fast in the command layer if --source is missing.
- Unit-test the import path with a valid sourcePath.
When it happens
Trigger: Calling importExternalAgentSession(cwd, {}) or importExternalAgentSession(cwd, { sourcePath: '' }). The caller resolved the transcript via resolveClaudeSessionPath but passed an undefined result, or the --source flag was dropped before reaching this function.
Common situations: A wrapper omitted the sourcePath field. resolveClaudeSessionPath returned undefined/null due to upstream logic and that was forwarded. A slash-command parsing bug dropped the argument.
Related errors
- A prompt is required for this Codex run.
- Could not identify the current Claude transcript. Retry with
- Claude session source must be a JSONL file: ${sourcePath}
- This Codex version does not support Claude session transfer.
- Codex reported that the Claude import completed, but did not
AI-assisted analysis of openai/codex-plugin-cc@db52e28f4d (2026-08-13).
Data as JSON: /api/errors/766a20268f5c6291.
Report an issue: GitHub.