affaan-m/ECC · error · anyhow::Error

Session not found: {value}

Error message

Session not found: {value}

What it means

Raised inside `resolve_session_id` for any value other than `"latest"`: `db.get_session(value)?` returned `None`, so no session row matches the supplied ID. This is the explicit-lookup counterpart to error 647 and is the error users see when they pass a concrete session ID that does not exist. The formatted message echoes the offending value.

Source

Thrown at ecc2/src/main.rs:2918

        }) => {
            session::manager::run_session(&cfg, &session_id, &task, &agent, &cwd).await?;
        }
    }

    Ok(())
}

fn resolve_session_id(db: &session::store::StateStore, value: &str) -> Result<String> {
    if value == "latest" {
        return db
            .get_latest_session()?
            .map(|session| session.id)
            .ok_or_else(|| anyhow::anyhow!("No sessions found"));
    }

    db.get_session(value)?
        .map(|session| session.id)
        .ok_or_else(|| anyhow::anyhow!("Session not found: {value}"))
}

fn sync_runtime_session_metrics(
    db: &session::store::StateStore,
    cfg: &config::Config,
) -> Result<()> {
    db.refresh_session_durations()?;
    db.sync_cost_tracker_metrics(&cfg.cost_metrics_path())?;
    db.sync_tool_activity_metrics(&cfg.tool_activity_metrics_path())?;
    let _ = session::manager::enforce_session_heartbeats(db, cfg)?;
    let _ = session::manager::enforce_budget_hard_limits(db, cfg)?;
    Ok(())
}

fn sync_memory_connector(
    db: &session::store::StateStore,
    cfg: &config::Config,
    name: &str,

View on GitHub (pinned to 01e15490f0)

Solutions

  1. List sessions to confirm valid IDs (e.g. `ecc sessions list`).
  2. Verify the state store path in config matches the workspace that owns the session.
  3. If you only need the most recent session, use the literal `latest` instead of an explicit ID.

Example fix

// before
ecc decisions abc123

// after
ecc sessions list            # find the real id
ecc decisions <valid-id>
Defensive patterns

Strategy: validation

Validate before calling

// Validate explicit session id before use
fn session_exists(db: &StateStore, id: &str) -> Result<bool> {
    Ok(db.get_session(id)?.is_some())
}

if !session_exists(&db, value)? {
    eprintln!("session not found: {value}; listing:");
    print_sessions(&db)?;
    return Ok(());
}

Try / catch

match db.get_session(value) {
    Ok(Some(s)) => s.id,
    Ok(None) => { eprintln!("Session not found: {value}"); std::process::exit(1); }
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Passing a session ID that was never created, was deleted, or belongs to a different state store. Typos in a copied ID. Truncation of a long UUID when copied from truncated log output. Using a session ID from a previous workspace.

Common situations: Wrong workspace / state DB. Stale references in scripts after a reset. ID format mismatch (e.g. integer vs UUID). Copy-paste errors from human-readable output that abbreviated the ID.

Related errors


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