BigPizzaV3/CodexPlusPlus · error · anyhow::Error
会话文件超过导入大小限制
Error message
会话文件超过导入大小限制
What it means
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.
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
Example fix
// before
let bytes = fs::read(source_path)?;
// after
let bytes = fs::read(source_path)?;
if bytes.len() > MAX_ROLLOUT_BYTES {
// 先压缩/裁剪会话行,或提升 MAX_ROLLOUT_BYTES
eprintln!("file too large: {} bytes", bytes.len());
return Ok(...);
} Defensive patterns
Strategy: validation
Validate before calling
let meta = std::fs::metadata(source_path)?;
if meta.len() > MAX_ROLLOUT_BYTES {
anyhow::bail!("文件 {} 超过导入大小限制", source_path.display());
} Try / catch
match import_rollout_file(&home, &path) {
Err(e) if e.to_string().contains("导入大小限制") => eprintln!("文件过大,请裁剪后重试"),
other => other?,
} Prevention
- 检查文件大小后再调用导入
- 定期轮转过大的会话文件
- 将 MAX_ROLLOUT_BYTES 纳入部署配置评审
When it happens
Trigger: Calling import_rollout_file(home, source_path) when fs::read returns bytes.len() > MAX_ROLLOUT_BYTES.
Common situations: 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.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/28feadae88b777b7.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/session_share.rs:149
let key = base64::engine::general_purpose::URL_SAFE_NO_PAD
.decode(key_value)
.context("分享链接解密密钥无效")?;
let iv = decode("iv")?;
let ciphertext = decode("ciphertext")?;
if key.len() != 32 || iv.len() != 12 || ciphertext.len() > MAX_ROLLOUT_BYTES + 16 {
bail!("分享数据大小或格式无效");
}
let cipher = Aes256Gcm::new_from_slice(&key).context("创建会话解密器失败")?;
cipher
.decrypt(Nonce::from_slice(&iv), ciphertext.as_ref())
.map_err(|_| anyhow::anyhow!("分享会话解密失败"))
}
pub fn import_rollout_file(home: &Path, source_path: &Path) -> anyhow::Result<Value> {
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())View on GitHub (pinned to b1ed92e5e4)