Hmbown/CodeWhale · error · std::io::Error

invalid session path

Error message

invalid session path

What it means

A generic InvalidInput guard raised while archiving a legacy work-state file: source.file_name() returned None, so the path terminates in '..' or is a filesystem root. The archive step needs a real file name to copy under, and cannot proceed without one.

Source

Thrown at crates/tui/src/session_manager.rs:1245

            .and_then(|state| state.graph.as_ref())
            .is_some_and(|graph| !graph.is_empty());
        if !writes_graph || !source.exists() {
            return Ok(());
        }
        let bytes = fs::read(source)?;
        let already_graph_backed = serde_json::from_slice::<SavedSession>(&bytes)
            .ok()
            .and_then(|saved| saved.work_state)
            .and_then(|state| state.graph)
            .is_some_and(|graph| !graph.is_empty());
        if already_graph_backed {
            return Ok(());
        }
        let archive_dir = self.sessions_dir.join(WORK_GRAPH_IMPORT_ARCHIVE_DIR);
        fs::create_dir_all(&archive_dir)?;
        let archive =
            archive_dir.join(source.file_name().ok_or_else(|| {
                io::Error::new(io::ErrorKind::InvalidInput, "invalid session path")
            })?);
        if !archive.exists() {
            write_atomic(&archive, &bytes)?;
        }
        Ok(())
    }

    fn read_checkpoint_file(&self, path: &Path) -> std::io::Result<Option<SavedSession>> {
        if !path.exists() {
            return Ok(None);
        }
        let content = fs::read_to_string(path)?;
        let mut session: SavedSession = serde_json::from_str(&content)
            .map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidData, e))?;
        if session.schema_version > CURRENT_SESSION_SCHEMA_VERSION {
            return Err(std::io::Error::new(
                std::io::ErrorKind::InvalidData,
                format!(

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Pass a concrete file path (not a root or '..-terminated path) as the session source
  2. Resolve the session path to a canonical file before invoking the archive/migration step
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/tui/src/session_manager.rs:1245 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/0827325c8afab15e. Report an issue: GitHub.