{"record":{"id":"668d8ca2f0301e47","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-668d8c","errorCode":null,"errorMessage":"不支持的会话文件格式","messagePattern":"不支持的会话文件格式","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/session_share.rs","lineNumber":203,"sourceCode":"    let path =\n        find_rollout(home, session_id).ok_or_else(|| anyhow::anyhow!(\"找不到原生会话文件\"))?;\n    let bytes = fs::read(&path).with_context(|| format!(\"读取会话文件失败：{}\", path.display()))?;\n    if bytes.len() > MAX_ROLLOUT_BYTES {\n        bail!(\"会话文件超过分享大小限制\");\n    }\n    let content = String::from_utf8(bytes).context(\"会话文件不是有效的 UTF-8\")?;\n    Ok(json!({\n        \"status\": \"ok\",\n        \"kind\": \"codex-rollout\",\n        \"session_id\": session_id,\n        \"content\": content,\n        \"filename\": path.file_name().and_then(|value| value.to_str()).unwrap_or(\"rollout.jsonl\"),\n    }))\n}\n\npub 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 {","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/session_share.rs#L185-L221","documentation":"import_rollout validates the payload structure of the decrypted share and found it does not match the expected codex-rollout JSONL layout (missing kind/session fields). The content decrypted fine but is structurally not a session file this importer accepts.","triggerScenarios":"Calling import_rollout(payload) directly with a payload lacking kind:\"codex-rollout\"; also reachable from import_shared_session_url / import_rollout_file when the decoded document is a different JSON shape.","commonSituations":"Sharing a hand-edited JSON file without the kind field; importing a payload from an older or newer share format version; passing an unrelated JSON document (e.g. settings or plain JSONL text) to the importer.","solutions":["Ensure the payload contains \"kind\": \"codex-rollout\" at the top level","Generate the payload via export_rollout instead of hand-crafting it","Check version compatibility between the producing and importing CodexPlusPlus versions"],"exampleFix":"// before\nlet payload = serde_json::json!({ \"session_id\": \"...\", \"content\": \"...\" });\nimport_rollout(&home, &payload)?;\n// after\nlet payload = serde_json::json!({\n    \"kind\": \"codex-rollout\",\n    \"session_id\": \"...\",\n    \"content\": \"...\"\n});\nimport_rollout(&home, &payload)?;","handlingStrategy":"validation","validationCode":"let v: serde_json::Value = serde_json::from_str(&raw)?;\nif v.get(\"kind\").and_then(|k| k.as_str()) != Some(\"codex-rollout\") {\n    anyhow::bail!(\"payload 缺少 kind=codex-rollout\");\n}","typeGuard":"fn is_rollout_payload(v: &serde_json::Value) -> bool {\n    v.get(\"kind\").and_then(serde_json::Value::as_str) == Some(\"codex-rollout\")\n}","tryCatchPattern":"match import_rollout(&home, &payload) {\n    Err(e) if e.to_string().contains(\"不支持的会话文件格式\") => eprintln!(\"请使用 export_rollout 生成的分享文件\"),\n    other => other?,\n}","preventionTips":["始终用 export_rollout 生成分享 payload","不要手工编辑 kind 字段","确认分享方与接收方版本兼容"],"tags":["validation","format","import"],"backgroundTag":"schema-validation-failed","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"}