BigPizzaV3/CodexPlusPlus · error · anyhow::Error
session_id cannot be empty
Error message
session_id cannot be empty
What it means
SessionRef::new validates that the session identifier is a non-empty string before constructing the SessionRef. An empty session_id would produce a reference that cannot address any session, so the constructor rejects it eagerly.
Solutions
- Pass the real session id string (e.g. the codex session UUID).
- Check the source of the id: only call new() after the id is known non-empty.
- If ids come from persisted data, validate on load and skip/surface records with empty ids.
- Ensure env vars/config providing the id are set before construction.
Example fix
// before
SessionRef::new("", "my session")?
// after
SessionRef::new("0f1e2d3c-4b5a-6789-abcd-ef0123456789", "my session")? Defensive patterns
Strategy: validation
Validate before calling
fn session_ref_checked(id: &str, title: &str) -> anyhow::Result<SessionRef> {
if id.trim().is_empty() {
anyhow::bail!("session id missing");
}
SessionRef::new(id, title)
} Try / catch
match SessionRef::new(id, title) {
Ok(r) => /* ... */,
Err(e) => { log::error!("invalid session ref: {e}"); skip_or_prompt_for_id(); }
} Prevention
- Only construct SessionRef after the id is obtained from a real session
- Validate ids when deserializing persisted session records
- Never default missing ids to the empty string; use Option instead
- Check env/config sources for the id are non-empty before use
When it happens
Trigger: Calling SessionRef::new("", "some title") or SessionRef::new(String::new(), title) — the title may be anything, only session_id is checked.
Common situations: Session id read from an uninitialized variable or empty env var; a UI passing a not-yet-selected session; deserializing a record whose id field is missing and defaulting to "".
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
- 会话 ID 为空
- 主题包必须是 32 MiB 以内的普通 ZIP 文件
- 请填写 API 的模型名称
- 官方混合 API 不应在 auth.json 中保存 OPENAI_API_KEY。请清理此供应商的…
- 请填写 API 的模型名称
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/956d69cc1e3e08e4.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/models.rs:14
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct SessionRef {
pub session_id: String,
pub title: String,
}
impl SessionRef {
pub fn new(
session_id: impl Into<String>,
title: impl Into<String>,
) -> anyhow::Result<SessionRef> {
let session_id = session_id.into();
if session_id.is_empty() {
anyhow::bail!("session_id cannot be empty");
}
Ok(SessionRef {
session_id,
title: title.into(),
})
}
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum DeleteStatus {
ServerDeleted,
LocalDeleted,
Partial,
Failed,
Undone,
}View on GitHub (pinned to b1ed92e5e4)