BigPizzaV3/CodexPlusPlus · error · anyhow::Error

会话 ID 为空

Error message

会话 ID 为空

What it means

Thrown by export_rollout when the trimmed session_id argument is empty. The function must locate the exact rollout file for the session; the offending input is the caller-supplied session id (blank), and the guard fires before any filesystem lookup starts.

Source

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

    let title = source_path
        .file_stem()
        .and_then(|value| value.to_str())
        .unwrap_or("导入的会话");
    import_rollout(
        home,
        &json!({
            "kind": "codex-rollout",
            "session_id": session_id,
            "content": content,
            "title": title,
        }),
    )
}

pub fn export_rollout(home: &Path, session_id: &str) -> anyhow::Result<Value> {
    let session_id = session_id.trim();
    if session_id.is_empty() {
        bail!("会话 ID 为空");
    }
    let path =
        find_rollout(home, session_id).ok_or_else(|| anyhow::anyhow!("找不到原生会话文件"))?;
    let bytes = fs::read(&path).with_context(|| format!("读取会话文件失败:{}", path.display()))?;
    if bytes.len() > MAX_ROLLOUT_BYTES {
        bail!("会话文件超过分享大小限制");
    }
    let content = String::from_utf8(bytes).context("会话文件不是有效的 UTF-8")?;
    Ok(json!({
        "status": "ok",
        "kind": "codex-rollout",
        "session_id": session_id,
        "content": content,
        "filename": path.file_name().and_then(|value| value.to_str()).unwrap_or("rollout.jsonl"),
    }))
}

pub fn import_rollout(home: &Path, payload: &Value) -> anyhow::Result<Value> {

View on GitHub (pinned to f2074595a2)

Solutions

  1. 传入要导出的会话 id
Defensive patterns

Strategy: validation

When it happens

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