aaif-goose/goose · error · anyhow::Error
Could not extract session ID from path: {:?}
Error message
Could not extract session ID from path: {:?} What it means
anyhow error from the resume branch (crates/goose-cli/src/cli.rs) when --path was supplied and Path::file_stem() returns None or the stem is not valid UTF-8. file_stem fails for paths whose last component is '..' (no stem) or a path like '/'; to_str() fails for non-UTF-8 bytes in the filename.
Source
Thrown at crates/goose-cli/src/cli.rs:432
.ok_or_else(|| anyhow::anyhow!("No session found to resume"))?;
return Ok(Some(session_id));
};
if let Some(session_id) = id.session_id {
session_id
} else if let Some(name) = id.name {
let sessions = session_manager.list_sessions().await?;
sessions
.into_iter()
.find(|s| s.name == name || s.id == name)
.map(|s| s.id)
.ok_or_else(|| anyhow::anyhow!("No session found with name '{}'", name))?
} else if let Some(path) = id.path {
path.file_stem()
.and_then(|s| s.to_str())
.map(|s| s.to_string())
.ok_or_else(|| {
anyhow::anyhow!("Could not extract session ID from path: {:?}", path)
})?
} else {
return Err(anyhow::anyhow!("Invalid identifier"));
}
} else {
let Some(id) = identifier else {
let session = session_manager
.create_session(
std::env::current_dir()?,
"CLI Session".to_string(),
SessionType::User,
goose_mode,
)
.await?;
return Ok(Some(session.id));
};
if id.session_id.is_some() {View on GitHub (pinned to 3810898a74)
Solutions
- Pass the full path to the session .jsonl file, not a directory: --path /path/to/20250325_200615.jsonl
- Avoid '.', '..', and '/' as the path value
- If the filename has non-UTF-8 bytes, rename the file to a UTF-8 name first
- Prefer the modern form instead: --resume --session-id 20250325_200615
Example fix
# before goose --resume --path ~/goose/sessions/ # after goose --resume --path ~/goose/sessions/20250325_200615.jsonl goose --resume --session-id 20250325_200615 # preferred
Defensive patterns
Strategy: validation
Validate before calling
let ok = path.is_file() && path.file_stem().and_then(|s| s.to_str()).is_some();
if !ok { /* reject early: pass the .jsonl file path, not a directory */ } Type guard
fn usable_session_path(path: &Path) -> bool {
path.is_file() && path.file_stem().and_then(|s| s.to_str()).is_some()
} Prevention
- Pass the full .jsonl file path, never a directory or '..'
- Prefer the modern --session-id form over legacy --path
- Sanitize non-UTF-8 filenames before passing them
When it happens
Trigger: Passing --path ., --path .., --path /, or a legacy session file path whose filename contains non-UTF-8 bytes. Normal '/path/to/20250325_200615.jsonl' works; only degenerate or non-UTF-8 paths hit this error.
Common situations: Passing a directory instead of the .jsonl file (e.g. --path ~/goose/sessions/), shell glob expanding to '..' or an empty result, filenames with invalid encoding after a filesystem migration.
Related errors
- No session found to resume
- No session found with name '{}'
- Invalid identifier
- Cannot use --session-id without --resume
- No identifier provided
AI-assisted analysis of aaif-goose/goose@3810898a74 (2026-08-16).
Data as JSON: /api/errors/0b9fa9e62575052c.
Report an issue: GitHub.