{"record":{"id":"7c1d1154d54c1362","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-7c1d11","errorCode":null,"errorMessage":"会话文件内容不完整","messagePattern":"会话文件内容不完整","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/session_share.rs","lineNumber":219,"sourceCode":"pub fn import_rollout(home: &Path, payload: &Value) -> anyhow::Result<Value> {\n    if payload.get(\"kind\").and_then(Value::as_str) != Some(\"codex-rollout\") {\n        bail!(\"不支持的会话文件格式\");\n    }\n    let source_id = payload\n        .get(\"session_id\")\n        .and_then(Value::as_str)\n        .unwrap_or_default();\n    let content = payload\n        .get(\"content\")\n        .and_then(Value::as_str)\n        .unwrap_or_default();\n    let title = payload\n        .get(\"title\")\n        .and_then(Value::as_str)\n        .unwrap_or(\"导入的会话\")\n        .trim();\n    if source_id.is_empty() || content.is_empty() {\n        bail!(\"会话文件内容不完整\");\n    }\n    if content.len() > MAX_ROLLOUT_BYTES {\n        bail!(\"会话文件超过导入大小限制\");\n    }\n    let new_id = Uuid::new_v4().to_string();\n    let rewritten = rewrite_rollout(content, source_id, &new_id)?;\n    let now = SystemTime::now()\n        .duration_since(UNIX_EPOCH)\n        .unwrap_or_default()\n        .as_secs();\n    let directory = home.join(\"sessions\").join(\"imported\");\n    fs::create_dir_all(&directory).context(\"创建会话目录失败\")?;\n    let path = directory.join(format!(\"rollout-{now}-{new_id}.jsonl\"));\n    fs::write(&path, rewritten).context(\"写入导入会话失败\")?;\n\n    register_imported_thread(home, &new_id, &path, title, content, now)?;\n\n    let index_path = home.join(\"session_index.jsonl\");","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/session_share.rs#L201-L237","documentation":"import_rollout requires both a non-empty source session_id and non-empty rollout content; if either is missing the shared file is deemed incomplete and rejected. This guards against writing a corrupted/empty session into the Codex home.","triggerScenarios":"import_rollout(payload) where payload.session_id is empty/absent or the content string is empty; also reachable via import_shared_session_url / import_rollout_file for such payloads.","commonSituations":"Truncated share payload (content stripped during copy/paste); exported file whose content field was lost in transit; payload built manually without session_id.","solutions":["Re-export the session with export_rollout to obtain a complete payload","Verify the share URL/file was not truncated (check content length) before importing","Include a non-empty session_id when constructing the payload manually"],"exampleFix":"// before\nlet payload = json!({ \"kind\": \"codex-rollout\", \"session_id\": \"\", \"content\": data });\n// after\nif source_id.is_empty() || content.is_empty() {\n    anyhow::bail!(\"分享内容缺失 session_id 或 content\");\n}\nlet payload = json!({ \"kind\": \"codex-rollout\", \"session_id\": source_id, \"content\": content });","handlingStrategy":"validation","validationCode":"if payload.get(\"session_id\").and_then(|v| v.as_str()).unwrap_or(\"\").trim().is_empty()\n    || payload.get(\"content\").and_then(|v| v.as_str()).unwrap_or(\"\").is_empty()\n{\n    anyhow::bail!(\"分享内容不完整\");\n}","typeGuard":"fn is_complete_payload(v: &serde_json::Value) -> bool {\n    !v.get(\"session_id\").and_then(serde_json::Value::as_str).unwrap_or(\"\").trim().is_empty()\n        && !v.get(\"content\").and_then(serde_json::Value::as_str).unwrap_or(\"\").is_empty()\n}","tryCatchPattern":null,"preventionTips":["传输前对 payload 做完整性校验（如长度/校验和）","避免复制粘贴截断，使用文件或 URL 传递","导入前打印 payload 键做快速体检"],"tags":["validation","import","incomplete-data"],"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"}