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

Session not found: {session_id}

Error message

Session not found: {session_id}

What it means

Thrown by build_otel_export when a specific session id is requested but StateStore.get_session returns None (no session row with that id exists). The OTEL exporter cannot build spans for a session that is not in the store, so it errors rather than emit an empty export.

Source

Thrown at ecc2/src/main.rs:8279

                    for line in preview.lines().take(6) {
                        lines.push(format!("    {}", line));
                    }
                }
            }
        }
    }

    lines.join("\n")
}

fn build_otel_export(
    db: &session::store::StateStore,
    session_id: Option<&str>,
) -> Result<OtlpExport> {
    let sessions = if let Some(session_id) = session_id {
        vec![db
            .get_session(session_id)?
            .ok_or_else(|| anyhow::anyhow!("Session not found: {session_id}"))?]
    } else {
        db.list_sessions()?
    };

    let mut spans = Vec::new();
    for session in &sessions {
        spans.extend(build_session_otel_spans(db, session)?);
    }

    Ok(OtlpExport {
        resource_spans: vec![OtlpResourceSpans {
            resource: OtlpResource {
                attributes: vec![
                    otlp_string_attr("service.name", "ecc2"),
                    otlp_string_attr("service.version", env!("CARGO_PKG_VERSION")),
                    otlp_string_attr("telemetry.sdk.language", "rust"),
                ],
            },

View on GitHub (pinned to 01e15490f0)

Solutions

  1. List sessions first (db.list_sessions() / the sessions list command) to confirm the id exists and copy the exact value.
  2. If the session was pruned, restore from backup or point the command at the store that still contains it.
  3. Call the export without --session to export all sessions and confirm the target id is present in the output.
  4. Check for trailing whitespace or quotes around the id when copy-pasting.

Example fix

# before
ecc2 otel export --session abc123
# (errors: Session not found: abc123)

# after: confirm the id first, then export
ecc2 sessions list | grep abc
ecc2 otel export --session abc123de-4567-89ef-...
Defensive patterns

Strategy: validation

Validate before calling

fn session_exists(db: &session::store::StateStore, id: &str) -> bool {
    db.get_session(id).ok().flatten().is_some()
}

// before exporting
let id = args.session.as_deref().unwrap();
if !session_exists(&db, id) {
    return Err(anyhow!("refusing export: unknown session {id}"));
}

Prevention

When it happens

Trigger: Calling the OTEL export command/API with --session <id> where <id> does not match any stored session. Causes include typos in the id, a session that was pruned/expired, a session id from a different StateStore database, or a session that was never persisted.

Common situations: Copying a session id from logs that reference a rotated-out store; transposing characters in the id; querying a store file that does not contain the session; the session finished and was archived.

Related errors


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