affaan-m/ECC · error

Session not found: {resolved_id}

Error message

Session not found: {resolved_id}

What it means

Runtime error from the WorktreeStatus command handler in ecc2/src/main.rs. In the single-session branch (not --all), the handler resolves the id via resolve_session_id and calls db.get_session(&resolved_id); on None it bails with "Session not found: {resolved_id}". The default id is the literal "latest", so the error can also fire when there are no sessions at all.

Source

Thrown at ecc2/src/main.rs:2009

            patch,
            check,
        }) => {
            if all && session_id.is_some() {
                return Err(anyhow::anyhow!(
                    "worktree-status does not accept a session ID when --all is set"
                ));
            }
            let reports = if all {
                session::manager::list_sessions(&db)?
                    .into_iter()
                    .map(|session| build_worktree_status_report(&session, patch))
                    .collect::<Result<Vec<_>>>()?
            } else {
                let id = session_id.unwrap_or_else(|| "latest".to_string());
                let resolved_id = resolve_session_id(&db, &id)?;
                let session = db
                    .get_session(&resolved_id)?
                    .ok_or_else(|| anyhow::anyhow!("Session not found: {resolved_id}"))?;
                vec![build_worktree_status_report(&session, patch)?]
            };
            if json {
                if all {
                    println!("{}", serde_json::to_string_pretty(&reports)?);
                } else {
                    println!("{}", serde_json::to_string_pretty(&reports[0])?);
                }
            } else {
                println!("{}", format_worktree_status_reports_human(&reports));
            }
            if check {
                std::process::exit(worktree_status_reports_exit_code(&reports));
            }
        }
        Some(Commands::WorktreeResolution {
            session_id,
            all,

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Run `sessions list` (or equivalent) to confirm the id and that any session exists.
  2. If the database is empty, create a session before asking for its worktree status.
  3. Pass the exact resolved id rather than relying on "latest".
  4. Check you are pointed at the right project/workspace database.

Example fix

# before
$ ecc worktree-status
Error: Session not found: latest

# after
$ ecc sessions list   # confirm sessions exist
$ ecc worktree-status <exact-id>
Defensive patterns

Strategy: validation

Validate before calling

// Special-case the 'latest' default against an empty database.
let id = session_id.as_deref().unwrap_or("latest");
if id == "latest" && session::manager::list_sessions(&db)?.is_empty() {
    eprintln!("no sessions exist; create one before requesting worktree status");
    return Ok(());
}

Type guard

fn session_exists(db: &Db, id: &str) -> bool {
    db.get_session(id).map(|o| o.is_some()).unwrap_or(false)
}

Try / catch

let session = db.get_session(&resolved_id)?.ok_or_else(|| {
    eprintln!("tip: run `ecc sessions list`");
    anyhow::anyhow!("Session not found: {resolved_id}")
})?;

Prevention

When it happens

Trigger: Running `worktree-status <id>` (or with no id, which defaults to "latest") where the resolved id does not exist in the database. Also fires when the database is empty and "latest" resolves to a non-existent sentinel.

Common situations: Empty session database and the user omitted the id (so it defaults to "latest"); typo in the id; the session was deleted; wrong workspace database selected.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/452cdcd85e2ae079. Report an issue: GitHub.