BigPizzaV3/CodexPlusPlus · error · anyhow::Error

会话文件内容不完整

Error message

会话文件内容不完整

What it means

Thrown by import_rollout when the payload's session_id or content is empty after extraction. Both are mandatory for rebuilding a session (content is the rollout JSONL body); the offending input is the incomplete import payload, and the guard fires before ID rewriting or database registration begins.

Source

Thrown at crates/codex-plus-core/src/session_share.rs:219

pub fn import_rollout(home: &Path, payload: &Value) -> anyhow::Result<Value> {
    if payload.get("kind").and_then(Value::as_str) != Some("codex-rollout") {
        bail!("不支持的会话文件格式");
    }
    let source_id = payload
        .get("session_id")
        .and_then(Value::as_str)
        .unwrap_or_default();
    let content = payload
        .get("content")
        .and_then(Value::as_str)
        .unwrap_or_default();
    let title = payload
        .get("title")
        .and_then(Value::as_str)
        .unwrap_or("导入的会话")
        .trim();
    if source_id.is_empty() || content.is_empty() {
        bail!("会话文件内容不完整");
    }
    if content.len() > MAX_ROLLOUT_BYTES {
        bail!("会话文件超过导入大小限制");
    }
    let new_id = Uuid::new_v4().to_string();
    let rewritten = rewrite_rollout(content, source_id, &new_id)?;
    let now = SystemTime::now()
        .duration_since(UNIX_EPOCH)
        .unwrap_or_default()
        .as_secs();
    let directory = home.join("sessions").join("imported");
    fs::create_dir_all(&directory).context("创建会话目录失败")?;
    let path = directory.join(format!("rollout-{now}-{new_id}.jsonl"));
    fs::write(&path, rewritten).context("写入导入会话失败")?;

    register_imported_thread(home, &new_id, &path, title, content, now)?;

    let index_path = home.join("session_index.jsonl");

View on GitHub (pinned to f2074595a2)

Solutions

  1. 确保导入 JSON 含非空 session_id 与 content
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/codex-plus-core/src/session_share.rs:219 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/7c1d1154d54c1362. Report an issue: GitHub.