Hmbown/CodeWhale · error
managed directory path cannot contain traversal components
Error message
managed directory path cannot contain traversal components
What it means
normalize_managed_dir rejects relative managed-directory paths that contain ParentDir ('..'), Prefix, or RootDir components. Such a path is either traversal-shaped or ill-formed, and allowing it would let session data be resolved outside the intended location depending on the process cwd. Absolute paths pass through unchanged.
Solutions
- Replace the relative traversal path with an absolute path in the config.
- Remove '..' components; if you need a shared location, use an absolute path (or ~ expanded by the loader).
- On Windows, supply a full path including drive and root (e.g. C:\Users\me\...), not a bare prefix.
- Verify cwd assumptions: even a benign relative path is fragile; prefer absolute or loader-expanded paths.
Example fix
// before sessions_dir = "../shared/sessions" // after sessions_dir = "/home/user/.local/share/codewhale/sessions"
Defensive patterns
Strategy: validation
Validate before calling
let p = PathBuf::from(raw);
if p.is_relative() && p.components().any(|c| matches!(c, std::path::Component::ParentDir | std::path::Component::Prefix(_) | std::path::Component::RootDir)) {
return Err(anyhow!("managed dir must not contain traversal components"));
} Prevention
- Store absolute (or loader-expanded ~) paths in config files.
- Reject '..' in user-supplied directories at intake.
- Document that managed paths are resolved absolutely, never relative to cwd.
When it happens
Trigger: Passing a relative path with '..' segments (e.g. "../shared/sessions"), a Windows prefix like "C:" without a root, or "/" mixed into a relative path to SessionManager::new; the check applies when the path is relative.
Common situations: Config written with '../' to point at a sibling project's sessions; relative paths copied from documentation that assumed a different cwd; hand-edited config on Windows leaving a bare drive prefix.
Understand the failure class
Background: Path traversal blocked: "path escapes the workspace" and "outside site root" errors when a path will not stay inside its allowed directory — this error's family across 26 libraries.
Related errors
- config path cannot contain '..' components
- agent profile provider cannot be empty
- agent profile provider must be a simple provider id
- api_key cannot be empty string
- approval_policy ' ' is not allowed by requirements ( )
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/4d62ceef4f4e1abb.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/session_manager.rs:124
const fn default_queue_schema_version() -> u32 {
CURRENT_QUEUE_SCHEMA_VERSION
}
fn normalize_managed_dir(path: PathBuf) -> std::io::Result<PathBuf> {
if path.as_os_str().is_empty() {
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"managed directory path cannot be empty",
));
}
if path.components().any(|component| {
matches!(
component,
Component::ParentDir | Component::Prefix(_) | Component::RootDir
)
}) && path.is_relative()
{
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"managed directory path cannot contain traversal components",
));
}
if path.is_absolute() {
return Ok(path);
}
std::env::current_dir().map(|cwd| cwd.join(path))
}
fn open_private_lock_file(path: &Path) -> io::Result<fs::File> {
let mut options = OpenOptions::new();
options.create(true).read(true).write(true);
#[cfg(unix)]
{
use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
options
.mode(0o600)View on GitHub (pinned to 73e0f67d83)