{"record":{"id":"0fdea5cf84a07837","repo":"aaif-goose/goose","slug":"session-has-no-messages-to-edit","errorCode":null,"errorMessage":"session has no messages to edit","messagePattern":"session has no messages to edit","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/goose-cli/src/cli.rs","lineNumber":1689,"sourceCode":"        if let Some(ref id) = session_id {\n            let session_manager = SessionManager::instance();\n            let original = session_manager.get_session(id, true).await?;\n\n            let target_id = if fork {\n                let copied = session_manager\n                    .copy_session(id, original.name.clone())\n                    .await?;\n                let copied_id = copied.id.clone();\n                session_id = Some(copied.id);\n                copied_id\n            } else {\n                id.clone()\n            };\n\n            if edit {\n                let conversation = original\n                    .conversation\n                    .ok_or_else(|| anyhow::anyhow!(\"session has no messages to edit\"))?;\n                let edited = crate::session::editor::edit_conversation(&conversation)?;\n                session_manager\n                    .replace_conversation(&target_id, &edited)\n                    .await?;\n            }\n        }\n    }\n\n    let mut session: crate::CliSession = build_session(SessionBuilderConfig {\n        session_id,\n        resume,\n        fork,\n        no_session: false,\n        extensions: extension_opts.extensions,\n        streamable_http_extensions: extension_opts.streamable_http_extensions,\n        builtins: extension_opts.builtins,\n        no_profile: extension_opts.no_profile,\n        recipe: None,","sourceCodeStart":1671,"sourceCodeEnd":1707,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-cli/src/cli.rs#L1671-L1707","documentation":"When a session is resumed with the edit flag, goose loads the stored session record and opens its `conversation` field in an external editor via edit_conversation. Sessions that were created but never received a message have `conversation: None`, and attempting to edit them is rejected.","triggerScenarios":"Invoking the resume-with-edit path (`--edit`) targeting a session id whose stored record has no conversation; also forked/copied sessions created from an original that was empty.","commonSituations":"Picking a session id from `goose session list` that was opened and immediately quit before the first message; a typo resolving to an empty session; automation resuming a session that errored on startup before any turn.","solutions":["Choose a session that actually contains messages (inspect it via the session list/viewer first)","If you want a clean slate, start a new session instead of editing an empty one","Send at least one message in that session before attempting to edit it"],"exampleFix":"# before\ngoose session --edit <id-of-empty-session>   # error: no messages to edit\n\n# after\ngoose session --edit <id-of-session-with-messages>","handlingStrategy":"validation","validationCode":"# Rust (embedding goose): confirm the session actually has a conversation first\nlet conversation = original.conversation.as_ref().filter(|c| !c.is_empty());\nif conversation.is_none() {\n    anyhow::bail!(\"cannot edit: session has no messages\");\n}","typeGuard":"fn is_editable(conversation: &Option<Vec<goose::message::Message>>) -> bool {\n    conversation.as_ref().is_some_and(|c| !c.is_empty())\n}","tryCatchPattern":null,"preventionTips":["Show message counts next to session ids in any session picker","Treat empty sessions as new conversations, never edit targets","Verify the id with `goose session list` before scripting --edit"],"tags":["session","cli","editing","input-validation"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}