{"record":{"id":"1fbf9fa4800a4864","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-1fbf9f","errorCode":null,"errorMessage":"会话文件没有内容","messagePattern":"会话文件没有内容","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/session_share.rs","lineNumber":440,"sourceCode":"                .file_name()\n                .and_then(|value| value.to_str())\n                .is_some_and(|name| name.contains(session_id))\n        {\n            return Some(path);\n        }\n    }\n    None\n}\n\nfn rewrite_rollout(content: &str, old_id: &str, new_id: &str) -> anyhow::Result<String> {\n    let mut lines = Vec::new();\n    for line in content.lines() {\n        let mut value: Value = serde_json::from_str(line).context(\"会话文件包含无效 JSON 行\")?;\n        replace_id(&mut value, old_id, new_id);\n        lines.push(serde_json::to_string(&value)?);\n    }\n    if lines.is_empty() {\n        bail!(\"会话文件没有内容\");\n    }\n    Ok(format!(\"{}\\n\", lines.join(\"\\n\")))\n}\n\nfn replace_id(value: &mut Value, old_id: &str, new_id: &str) {\n    match value {\n        Value::String(text) if text == old_id => *text = new_id.to_string(),\n        Value::Array(items) => items\n            .iter_mut()\n            .for_each(|item| replace_id(item, old_id, new_id)),\n        Value::Object(object) => object\n            .values_mut()\n            .for_each(|item| replace_id(item, old_id, new_id)),\n        _ => {}\n    }\n}\n\nfn find_session_id(content: &str) -> Option<String> {","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/session_share.rs#L422-L458","documentation":"rewrite_rollout splits the rollout content into JSONL lines, rewrites the session ID in each, and rejects content that yields no lines. Empty content here would produce an empty session file, so the library treats it as an error.","triggerScenarios":"import_rollout or rewrites_ids_in_rollout_lines calling rewrite_rollout with a content string that has no lines (empty or whitespace-only).","commonSituations":"A share payload whose content field is present but blank (e.g. only newlines); content stripped to whitespace by an earlier transformation; upstream export produced an empty body.","solutions":["Inspect the payload's content field and ensure it contains at least one JSONL line","Re-export the session via export_rollout to regenerate valid content","Fix whatever producer emitted whitespace-only content (transport truncation, bad paste)"],"exampleFix":"// before\nlet rewritten = rewrite_rollout(\"\\n\\n\", &old_id, &new_id)?; // bails\n// after\nlet content = content.trim();\nif content.is_empty() {\n    anyhow::bail!(\"会话内容为空，无法导入\");\n}\nlet rewritten = rewrite_rollout(content, &old_id, &new_id)?;","handlingStrategy":"validation","validationCode":"if content.trim().is_empty() {\n    anyhow::bail!(\"会话内容为空\");\n}","typeGuard":"fn has_rollout_lines(content: &str) -> bool {\n    content.lines().any(|l| !l.trim().is_empty())\n}","tryCatchPattern":null,"preventionTips":["导入前 trim 并检查内容非空","排查产生空白内容的导出/传输环节","对分享内容加最小行数校验"],"tags":["validation","empty-content","import"],"backgroundTag":"empty-required-field","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}