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

  1. Pass the real session id string (e.g. the codex session UUID).
  2. Check the source of the id: only call new() after the id is known non-empty.
  3. If ids come from persisted data, validate on load and skip/surface records with empty ids.
  4. 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

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


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)