BigPizzaV3/CodexPlusPlus · error
无法从会话文件识别会话 ID
Error message
无法从会话文件识别会话 ID
What it means
import_rollout_file imports a native codex rollout file and needs a session ID. It first searches the file content for a UUID; failing that, it tries to extract one from the file's stem. If neither yields a UUID, it cannot identify the session and raises this error. Without a session ID the rollout cannot be registered.
Solutions
- Rename the file to include the session UUID, e.g. rollout-2025-01-01T00-00-00-<uuid>.jsonl.
- Check the rollout file is a complete native codex session file containing the session id in its header.
- Regenerate the export from codex so the original UUID-bearing filename is preserved.
- Inspect the file for a UUID and patch the header/filename manually if it is a partial export.
Example fix
// before mv export.json ~/.codex/sessions/ // after mv export.json ~/.codex/sessions/rollout-2025-06-01T12-00-00-3f2a1b8c-9d4e-4f01-8a2b-7c6d5e4f3a2b.jsonl
Defensive patterns
Strategy: validation
Validate before calling
const UUID_RE = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
function importableRollout(path: string, content: string): boolean {
return UUID_RE.test(content) || UUID_RE.test(path);
} Try / catch
try {
await api.importRolloutFile(path);
} catch (e) {
if (String(e).includes('无法从会话文件识别会话 ID')) {
alert('文件名与内容均无会话 ID,请恢复原始 rollout 文件名');
} else { throw e; }
} Prevention
- Never rename rollout files; keep codex's UUID-bearing names.
- Export sessions via the app's own export function.
- Verify rollout files are complete (header record present).
- Scan file content for a UUID before importing manually.
When it happens
Trigger: Importing a rollout file whose JSON contains no UUID-shaped session id and whose filename has no UUID (e.g. "session.json", "export.txt").
Common situations: Renamed or hand-exported rollout files; files from other tools with non-UUID session identifiers; truncated rollout content missing the header record.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/517c80c92ff5d314.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/session_share.rs:164
let bytes = fs::read(source_path)
.with_context(|| format!("读取会话文件失败:{}", source_path.display()))?;
if bytes.len() > MAX_ROLLOUT_BYTES {
bail!("会话文件超过导入大小限制");
}
let content = String::from_utf8(bytes).context("会话文件不是有效的 UTF-8")?;
if let Ok(payload) = serde_json::from_str::<Value>(&content)
&& payload.get("kind").and_then(Value::as_str) == Some("codex-rollout")
{
return import_rollout(home, &payload);
}
let session_id = find_session_id(&content)
.or_else(|| {
source_path
.file_stem()
.and_then(|value| value.to_str())
.and_then(find_uuid)
})
.ok_or_else(|| anyhow::anyhow!("无法从会话文件识别会话 ID"))?;
let title = source_path
.file_stem()
.and_then(|value| value.to_str())
.unwrap_or("导入的会话");
import_rollout(
home,
&json!({
"kind": "codex-rollout",
"session_id": session_id,
"content": content,
"title": title,
}),
)
}
pub fn export_rollout(home: &Path, session_id: &str) -> anyhow::Result<Value> {
let session_id = session_id.trim();
if session_id.is_empty() {View on GitHub (pinned to b1ed92e5e4)