From b9b7ed5a6ad0d5163e703d09fe5cd8d85e2c0f12 Mon Sep 17 00:00:00 2001 From: Max Novich Date: Mon, 30 Jun 2025 13:37:33 -0700 Subject: [PATCH] allow to use dev/null for no-session mode (#3176) --- crates/goose/src/session/storage.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/crates/goose/src/session/storage.rs b/crates/goose/src/session/storage.rs index 01c23da4..4e5d1305 100644 --- a/crates/goose/src/session/storage.rs +++ b/crates/goose/src/session/storage.rs @@ -158,6 +158,14 @@ pub fn get_path(id: Identifier) -> Result { session_dir.join(format!("{}.jsonl", name)) } Identifier::Path(path) => { + // Allow special paths for no-session mode + if let Some(path_str) = path.to_str() { + if path_str == "/dev/null" || path_str == "NUL" { + // These are special paths used for --no-session mode + return Ok(path); + } + } + // In test mode, allow temporary directory paths #[cfg(test)] { @@ -190,10 +198,14 @@ pub fn get_path(id: Identifier) -> Result { } }; - // Additional security check for file extension - if let Some(ext) = path.extension() { - if ext != "jsonl" { - return Err(anyhow::anyhow!("Invalid file extension")); + // Additional security check for file extension (skip for special no-session paths) + if let Some(path_str) = path.to_str() { + if path_str != "/dev/null" && path_str != "NUL" { + if let Some(ext) = path.extension() { + if ext != "jsonl" { + return Err(anyhow::anyhow!("Invalid file extension")); + } + } } }