aaif-goose/goose · error

Session with name '{}' not found.

Error message

Session with name '{}' not found.

What it means

Thrown by `goose session remove --name <NAME>` when no session in list_all_sessions() has a name field exactly equal to the argument. Matching is exact and case-sensitive, and unnamed sessions store an empty string as their name. Because lookup goes through list_all_sessions(), hidden sessions are included — a miss means no session of any visibility carries that name.

Source

Thrown at crates/goose-cli/src/commands/session.rs:112

    session_id: Option<String>,
    name: Option<String>,
    regex_string: Option<String>,
) -> Result<()> {
    let session_manager = SessionManager::instance();

    let matched_sessions: Vec<Session>;

    if let Some(id_val) = session_id {
        match session_manager.get_session(&id_val, false).await {
            Ok(session) => matched_sessions = vec![session],
            Err(_) => return Err(anyhow::anyhow!("Session ID '{}' not found.", id_val)),
        }
    } else if let Some(name_val) = name {
        let all_sessions = session_manager.list_all_sessions().await?;
        if let Some(session) = all_sessions.into_iter().find(|s| s.name == name_val) {
            matched_sessions = vec![session];
        } else {
            return Err(anyhow::anyhow!(
                "Session with name '{}' not found.",
                name_val
            ));
        }
    } else if let Some(regex_val) = regex_string {
        let session_regex = Regex::new(&regex_val)
            .with_context(|| format!("Invalid regex pattern '{}'", regex_val))?;

        let visible_sessions = session_manager.list_sessions().await?;
        matched_sessions = visible_sessions
            .into_iter()
            .filter(|session| session_regex.is_match(&session.id))
            .collect();

        if matched_sessions.is_empty() {
            println!("Regex string '{}' does not match any sessions", regex_val);
            return Ok(());
        }

View on GitHub (pinned to 3810898a74)

Solutions

  1. Run `goose session list` and copy the displayed name exactly (watch casing and whitespace)
  2. Remove by ID (`--id`) or regex (`--regex`) instead
  3. Confirm the session is stored under the current GOOSE_CONFIG_DIR/GOOSE_HOME

Example fix

# before
goose session remove --name MySession
# after
goose session list                # shows exact name, e.g. "my session"
goose session remove --name 'my session'
Defensive patterns

Strategy: validation

Validate before calling

let all = session_manager.list_all_sessions().await?;
if !all.iter().any(|s| s.name == name_val) {
    return Ok(());
}
handle_session_remove(None, Some(name_val), None).await?;

Type guard

fn session_name_exists(sessions: &[Session], name: &str) -> bool {
    sessions.iter().any(|s| s.name == name)
}

Try / catch

if let Err(e) = handle_session_remove(None, Some(name), None).await {
    if e.to_string().contains("with name") && e.to_string().contains("not found") {
        // name already removed; continue
    } else {
        return Err(e);
    }
}

Prevention

When it happens

Trigger: `goose session remove --name "my session"` with wrong casing, extra whitespace, or quotes; the session was renamed or never named (its name is ""); the name contains unicode differences from the listed value.

Common situations: Typing a name from memory instead of copying from `goose session list`; sessions created by older goose versions that did not persist names; names set only after a session was resumed.

Related errors


AI-assisted analysis of aaif-goose/goose@3810898a74 (2026-08-16). Data as JSON: /api/errors/7a5628103949f57c. Report an issue: GitHub.