{"record":{"id":"288931841a551d0c","repo":"affaan-m/ECC","slug":"session-not-found-session-id","errorCode":null,"errorMessage":"Session not found: {session_id}","messagePattern":"Session not found: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ecc2/src/main.rs","lineNumber":8279,"sourceCode":"                    for line in preview.lines().take(6) {\n                        lines.push(format!(\"    {}\", line));\n                    }\n                }\n            }\n        }\n    }\n\n    lines.join(\"\\n\")\n}\n\nfn build_otel_export(\n    db: &session::store::StateStore,\n    session_id: Option<&str>,\n) -> Result<OtlpExport> {\n    let sessions = if let Some(session_id) = session_id {\n        vec![db\n            .get_session(session_id)?\n            .ok_or_else(|| anyhow::anyhow!(\"Session not found: {session_id}\"))?]\n    } else {\n        db.list_sessions()?\n    };\n\n    let mut spans = Vec::new();\n    for session in &sessions {\n        spans.extend(build_session_otel_spans(db, session)?);\n    }\n\n    Ok(OtlpExport {\n        resource_spans: vec![OtlpResourceSpans {\n            resource: OtlpResource {\n                attributes: vec![\n                    otlp_string_attr(\"service.name\", \"ecc2\"),\n                    otlp_string_attr(\"service.version\", env!(\"CARGO_PKG_VERSION\")),\n                    otlp_string_attr(\"telemetry.sdk.language\", \"rust\"),\n                ],\n            },","sourceCodeStart":8261,"sourceCodeEnd":8297,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/ecc2/src/main.rs#L8261-L8297","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["List sessions first (db.list_sessions() / the sessions list command) to confirm the id exists and copy the exact value.","If the session was pruned, restore from backup or point the command at the store that still contains it.","Call the export without --session to export all sessions and confirm the target id is present in the output.","Check for trailing whitespace or quotes around the id when copy-pasting."],"exampleFix":"# before\necc2 otel export --session abc123\n# (errors: Session not found: abc123)\n\n# after: confirm the id first, then export\necc2 sessions list | grep abc\necc2 otel export --session abc123de-4567-89ef-...","handlingStrategy":"validation","validationCode":"fn session_exists(db: &session::store::StateStore, id: &str) -> bool {\n    db.get_session(id).ok().flatten().is_some()\n}\n\n// before exporting\nlet id = args.session.as_deref().unwrap();\nif !session_exists(&db, id) {\n    return Err(anyhow!(\"refusing export: unknown session {id}\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always list sessions and copy the exact id before exporting.","Validate the id format (UUID) before looking it up.","Use the same store the session was created in."],"tags":["otel","session","state-store","input-validation"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}