{"record":{"id":"dce48af5dea20d8c","repo":"aaif-goose/goose","slug":"session-has-no-messages","errorCode":null,"errorMessage":"Session has no messages","messagePattern":"Session has no messages","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/goose-cli/src/commands/session.rs","lineNumber":251,"sourceCode":"    let session_manager = SessionManager::instance();\n    let session = match session_manager.get_session(&session_id, true).await {\n        Ok(session) => session,\n        Err(e) => {\n            return Err(anyhow::anyhow!(\n                \"Session '{}' not found or failed to read: {}\",\n                session_id,\n                e\n            ));\n        }\n    };\n\n    let output = match format.as_str() {\n        \"json\" => serde_json::to_string_pretty(&session)?,\n        \"yaml\" => serde_yaml::to_string(&session)?,\n        \"markdown\" => {\n            let conversation = session\n                .conversation\n                .ok_or_else(|| anyhow::anyhow!(\"Session has no messages\"))?;\n            export_session_to_markdown(conversation.user_visible_messages(), &session.name)\n        }\n        _ => return Err(anyhow::anyhow!(\"Unsupported format: {}\", format)),\n    };\n\n    #[cfg(feature = \"nostr\")]\n    if nostr {\n        if format != \"json\" {\n            return Err(anyhow::anyhow!(\n                \"Nostr session sharing only supports --format json\"\n            ));\n        }\n        if output_path.is_some() {\n            return Err(anyhow::anyhow!(\n                \"Nostr session sharing cannot be combined with --output\"\n            ));\n        }\n","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-cli/src/commands/session.rs#L233-L269","documentation":"Raised only for `--format markdown`: markdown export renders the conversation transcript, so session.conversation must be Some. Sessions that were created but never recorded messages (or migrated/imported files lacking the conversation field) have conversation = None and cannot be rendered as markdown. JSON and YAML export work because they serialize the whole session object.","triggerScenarios":"`goose session export <id> --format markdown` on a session with zero messages; exporting a just-created session before any turn completes; importing a transcript that goose stored without a conversation payload.","commonSituations":"Testing export on a throwaway empty session; exporting immediately after `goose session start` before chatting; sessions created by headless/automation runs that errored out before writing messages.","solutions":["Export the same session as --format json or yaml (they do not require messages)","Pick a session that actually has messages (`goose session list` shows activity)","Send at least one message in the session before markdown export"],"exampleFix":"# before\ngoose session export <empty-session-id> --format markdown\n# after\ngoose session export <empty-session-id> --format json\ngoose session export <session-with-messages> --format markdown","handlingStrategy":"validation","validationCode":"let session = session_manager.get_session(&id, true).await?;\nlet format = if session_has_messages(&session) { \"markdown\" } else { \"json\" };","typeGuard":"fn session_has_messages(s: &Session) -> bool {\n    s.conversation\n        .as_ref()\n        .is_some_and(|c| !c.user_visible_messages().is_empty())\n}","tryCatchPattern":"match handle_session_export(id, None, \"markdown\".into(), false, vec![]).await {\n    Err(e) if e.to_string() == \"Session has no messages\" => {\n        handle_session_export(id, None, \"json\".into(), false, vec![]).await // fall back to json\n    }\n    other => other,\n}","preventionTips":["Default to json for automation; markdown only for sessions you know have traffic","Check a session has activity in `goose session list` before markdown export"],"tags":["session","export","markdown","empty-state"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}