BigPizzaV3/CodexPlusPlus · error · anyhow::Error

会话文件没有内容

Error message

会话文件没有内容

What it means

Thrown by rewrite_rollout when the input content parsed line-by-line fine but produced zero lines — there is nothing to rewrite IDs in. The offending input is the rollout content string passed by import_rollout: effectively empty of JSONL lines despite passing earlier non-empty checks, so the import refuses to emit an empty rewritten file.

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 f2074595a2)

Solutions

  1. 确认源文件是非空的 rollout JSONL
  2. 重新导出会话再导入
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/codex-plus-core/src/session_share.rs:440 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@f2074595a2 (2026-08-23). Data as JSON: /api/errors/1fbf9fa4800a4864. Report an issue: GitHub.