{"record":{"id":"28feadae88b777b7","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-28fead","errorCode":null,"errorMessage":"会话文件超过导入大小限制","messagePattern":"会话文件超过导入大小限制","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/session_share.rs","lineNumber":149,"sourceCode":"    let key = base64::engine::general_purpose::URL_SAFE_NO_PAD\n        .decode(key_value)\n        .context(\"分享链接解密密钥无效\")?;\n    let iv = decode(\"iv\")?;\n    let ciphertext = decode(\"ciphertext\")?;\n    if key.len() != 32 || iv.len() != 12 || ciphertext.len() > MAX_ROLLOUT_BYTES + 16 {\n        bail!(\"分享数据大小或格式无效\");\n    }\n    let cipher = Aes256Gcm::new_from_slice(&key).context(\"创建会话解密器失败\")?;\n    cipher\n        .decrypt(Nonce::from_slice(&iv), ciphertext.as_ref())\n        .map_err(|_| anyhow::anyhow!(\"分享会话解密失败\"))\n}\n\npub fn import_rollout_file(home: &Path, source_path: &Path) -> anyhow::Result<Value> {\n    let bytes = fs::read(source_path)\n        .with_context(|| format!(\"读取会话文件失败：{}\", source_path.display()))?;\n    if bytes.len() > MAX_ROLLOUT_BYTES {\n        bail!(\"会话文件超过导入大小限制\");\n    }\n    let content = String::from_utf8(bytes).context(\"会话文件不是有效的 UTF-8\")?;\n    if let Ok(payload) = serde_json::from_str::<Value>(&content)\n        && payload.get(\"kind\").and_then(Value::as_str) == Some(\"codex-rollout\")\n    {\n        return import_rollout(home, &payload);\n    }\n    let session_id = find_session_id(&content)\n        .or_else(|| {\n            source_path\n                .file_stem()\n                .and_then(|value| value.to_str())\n                .and_then(find_uuid)\n        })\n        .ok_or_else(|| anyhow::anyhow!(\"无法从会话文件识别会话 ID\"))?;\n    let title = source_path\n        .file_stem()\n        .and_then(|value| value.to_str())","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/session_share.rs#L131-L167","documentation":"import_rollout_file refuses to import rollout files larger than MAX_ROLLOUT_BYTES. The library enforces a hard size cap on session files at import time to bound memory use and SQLite/JSONL rewrite cost, and aborts with this message before parsing the content.","triggerScenarios":"Calling import_rollout_file(home, source_path) when fs::read returns bytes.len() > MAX_ROLLOUT_BYTES.","commonSituations":"Importing a large codex rollout JSONL exported from a long-running session; a user drops an oversized session dump on the importer; cumulative history in a rollout file grew past the configured limit.","solutions":["Trim the rollout file (remove old session lines) so it is under MAX_ROLLOUT_BYTES before importing","Raise the MAX_ROLLOUT_BYTES constant in crates/codex-plus-core/src/session_share.rs if larger imports are acceptable in your deployment","Split the session and import only the needed portion via import_rollout with a hand-built payload"],"exampleFix":"// before\nlet bytes = fs::read(source_path)?;\n// after\nlet bytes = fs::read(source_path)?;\nif bytes.len() > MAX_ROLLOUT_BYTES {\n    // 先压缩/裁剪会话行，或提升 MAX_ROLLOUT_BYTES\n    eprintln!(\"file too large: {} bytes\", bytes.len());\n    return Ok(...);\n}","handlingStrategy":"validation","validationCode":"let meta = std::fs::metadata(source_path)?;\nif meta.len() > MAX_ROLLOUT_BYTES {\n    anyhow::bail!(\"文件 {} 超过导入大小限制\", source_path.display());\n}","typeGuard":null,"tryCatchPattern":"match import_rollout_file(&home, &path) {\n    Err(e) if e.to_string().contains(\"导入大小限制\") => eprintln!(\"文件过大，请裁剪后重试\"),\n    other => other?,\n}","preventionTips":["检查文件大小后再调用导入","定期轮转过大的会话文件","将 MAX_ROLLOUT_BYTES 纳入部署配置评审"],"tags":["file-size","import","validation"],"backgroundTag":"file-size-limit-exceeded","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"}