BigPizzaV3/CodexPlusPlus · error · anyhow::Error
会话文件没有内容
Error message
会话文件没有内容
What it means
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.
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)
Example fix
// before
let rewritten = rewrite_rollout("\n\n", &old_id, &new_id)?; // bails
// after
let content = content.trim();
if content.is_empty() {
anyhow::bail!("会话内容为空,无法导入");
}
let rewritten = rewrite_rollout(content, &old_id, &new_id)?; Defensive patterns
Strategy: validation
Validate before calling
if content.trim().is_empty() {
anyhow::bail!("会话内容为空");
} Type guard
fn has_rollout_lines(content: &str) -> bool {
content.lines().any(|l| !l.trim().is_empty())
} Prevention
- 导入前 trim 并检查内容非空
- 排查产生空白内容的导出/传输环节
- 对分享内容加最小行数校验
When it happens
Trigger: import_rollout or rewrites_ids_in_rollout_lines calling rewrite_rollout with a content string that has no lines (empty or whitespace-only).
Common situations: 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.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/1fbf9fa4800a4864.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/session_share.rs:440
.file_name()
.and_then(|value| value.to_str())
.is_some_and(|name| name.contains(session_id))
{
return Some(path);
}
}
None
}
fn rewrite_rollout(content: &str, old_id: &str, new_id: &str) -> anyhow::Result<String> {
let mut lines = Vec::new();
for line in content.lines() {
let mut value: Value = serde_json::from_str(line).context("会话文件包含无效 JSON 行")?;
replace_id(&mut value, old_id, new_id);
lines.push(serde_json::to_string(&value)?);
}
if lines.is_empty() {
bail!("会话文件没有内容");
}
Ok(format!("{}\n", lines.join("\n")))
}
fn replace_id(value: &mut Value, old_id: &str, new_id: &str) {
match value {
Value::String(text) if text == old_id => *text = new_id.to_string(),
Value::Array(items) => items
.iter_mut()
.for_each(|item| replace_id(item, old_id, new_id)),
Value::Object(object) => object
.values_mut()
.for_each(|item| replace_id(item, old_id, new_id)),
_ => {}
}
}
fn find_session_id(content: &str) -> Option<String> {View on GitHub (pinned to b1ed92e5e4)