affaan-m/ECC · error · anyhow::Error
Session not found
Error message
Session not found: {from_id} What it means
The `follow` command with an explicit source session resolves the given session reference to an ID via `resolve_session_id`, then loads it from the database with `db.get_session`. When the lookup returns no row, the code bails with this error. It means the referenced session does not exist (or was deleted) in the local database.
Solutions
- List existing sessions (`ecc2 sessions` or equivalent) and copy the exact ID of the session you want to follow.
- If you meant the most recent session, omit the explicit session reference so the default 'latest' resolution applies.
- Check you are running ecc2 in the same project/data directory that contains the session.
- If the session should exist, verify the database file was not deleted or relocated.
Example fix
// before
let source = db.get_session(&from_id)?.ok_or_else(|| anyhow::anyhow!("Session not found: {from_id}"))?;
// after (guard earlier with a friendly hint)
let source = db.get_session(&from_id)?.ok_or_else(|| anyhow::anyhow!(
"Session not found: {from_id} (run `ecc2 sessions` to list valid IDs)"
))?; Defensive patterns
Strategy: validation
Validate before calling
// shell: confirm the session exists before following
ecc2 sessions --json | jq -e --arg id "$FROM_ID" 'map(.id) | index($id)' >/dev/null || { echo "session $FROM_ID not found"; exit 1; } Type guard
fn session_exists(db: &Db, id: &str) -> anyhow::Result<bool> {
Ok(db.get_session(id)?.is_some())
} Try / catch
// match on the resolved row and give a listing hint
match db.get_session(&from_id)? {
Some(s) => use_session(s),
None => eprintln!("session {from_id} not found; run `ecc2 sessions` to list IDs"),
} Prevention
- Always copy session IDs from the `sessions` list output, never from memory or other machines.
- Omit the explicit source reference when you mean the latest session.
- Pin your working directory before running session commands so the correct database is used.
- Avoid deleting sessions that are still referenced by follow/fork workflows.
When it happens
Trigger: Running `ecc2 follow <session-ref> ...` (with from_session set) where the resolved ID has no matching row in the sessions table.
Common situations: Referencing a session from a different project/database; the session was pruned or deleted; passing a stale short ID after the database was recreated; copying a session ID from another machine.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- Context graph observation #
- No sessions found
- Session not found
- Session not found
- an active harness configuration already exists
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/5fc55bd537f8836a.
Report an issue: GitHub.
Appendix: source
Thrown at ecc2/src/main.rs:1521
);
}
},
Some(Commands::Dashboard) | None => {
tui::app::run(db, cfg).await?;
}
Some(Commands::Start {
task,
agent,
profile,
worktree,
from_session,
}) => {
let use_worktree = worktree.resolve(&cfg);
let source = if let Some(from_session) = from_session.as_ref() {
let from_id = resolve_session_id(&db, from_session)?;
Some(
db.get_session(&from_id)?
.ok_or_else(|| anyhow::anyhow!("Session not found: {from_id}"))?,
)
} else {
None
};
let grouping = session::SessionGrouping {
project: source.as_ref().map(|session| session.project.clone()),
task_group: source.as_ref().map(|session| session.task_group.clone()),
};
let session_id = if let Some(source) = source.as_ref() {
session::manager::create_session_from_source_with_profile_and_grouping(
&db,
&cfg,
&task,
agent.as_deref().unwrap_or(&cfg.default_agent),
use_worktree,
profile.as_deref(),
&source.id,
grouping,View on GitHub (pinned to 8321021c54)