Hmbown/CodeWhale · error · io::Error

Offline queue cannot be parked without a session id

Error message

Offline queue cannot be parked without a session id

What it means

save_offline_queue_state persists the offline queue to a per-session path, so a session id is mandatory. Passing None makes the target path undefined; the API returns InvalidInput with "Offline queue cannot be parked without a session id" instead of guessing a global location.

Solutions

  1. Pass the active session's id (Some(session_id)) to save_offline_queue_state
  2. Fix the calling code to create/resolve the session before parking the offline queue
  3. If queue state truly has no session yet, defer parking until a session id exists, or buffer it in memory

Example fix

// before
manager.save_offline_queue_state(&state, None)?;
// after
let session_id = session.id().to_string();
manager.save_offline_queue_state(&state, Some(&session_id))?;
Defensive patterns

Strategy: validation

Validate before calling

if session_id.is_none() {
    return Err("cannot park the offline queue before a session exists".into());
}
manager.save_offline_queue_state(&state, session_id)?;

Try / catch

match session_id {
    Some(id) => manager.save_offline_queue_state(&state, Some(id))?,
    None => eprintln!("deferring offline-queue park until a session id is assigned"),
}

Prevention

When it happens

Trigger: Calling save_offline_queue_state(&state, None) — typically from a code path that parks queued input before a session id was assigned or after it was cleared.

Common situations: Parking the offline queue during early startup before session creation; a shutdown path that lost track of the active session id; a refactor that made session_id optional at the call site.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/67af95fb899c0457. Report an issue: GitHub.

Appendix: source

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

        }))
    }

    /// Park this session's offline queue (queued + draft messages).
    ///
    /// Queues are keyed per session (`checkpoints/<session_id>.offline_queue.json`)
    /// for exactly the reason checkpoints are: concurrent Codewhale instances
    /// must never overwrite — or delete — each other's unsent user text.
    ///
    /// A queue with no session id has no owner to restore it to, so parking is
    /// refused rather than written to a shared file where the next boot would
    /// destroy it.
    pub fn save_offline_queue_state(
        &self,
        state: &OfflineQueueState,
        session_id: Option<&str>,
    ) -> std::io::Result<PathBuf> {
        let session_id = session_id.ok_or_else(|| {
            std::io::Error::new(
                std::io::ErrorKind::InvalidInput,
                "Offline queue cannot be parked without a session id",
            )
        })?;
        let path = self.validated_offline_queue_path(session_id)?;
        fs::create_dir_all(self.checkpoints_dir())?;
        let mut owned = state.clone();
        // The stamp is redundant with the file name; it stays because the UI's
        // restore path still compares it against the live session id.
        owned.session_id = Some(self.validated_session_id(session_id)?.to_string());
        let content = serde_json::to_string_pretty(&owned)
            .map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidData, e))?;
        write_atomic(&path, content.as_bytes())?;
        Ok(path)
    }

    /// Load one session's parked offline queue if present.
    pub fn load_offline_queue_state(

View on GitHub (pinned to 73e0f67d83)