{"record":{"id":"1522ca75ddceff1c","repo":"Hmbown/CodeWhale","slug":"managed-directory-path-cannot-be-empty","errorCode":null,"errorMessage":"managed directory path cannot be empty","messagePattern":"managed directory path cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/session_manager.rs","lineNumber":112,"sourceCode":"\nfn is_sha256_fingerprint(value: &str) -> bool {\n    value.len() == 64\n        && value\n            .bytes()\n            .all(|byte| byte.is_ascii_digit() || (b'a'..=b'f').contains(&byte))\n}\n\nconst fn default_session_schema_version() -> u32 {\n    CURRENT_SESSION_SCHEMA_VERSION\n}\n\nconst fn default_queue_schema_version() -> u32 {\n    CURRENT_QUEUE_SCHEMA_VERSION\n}\n\nfn normalize_managed_dir(path: PathBuf) -> std::io::Result<PathBuf> {\n    if path.as_os_str().is_empty() {\n        return Err(std::io::Error::new(\n            std::io::ErrorKind::InvalidInput,\n            \"managed directory path cannot be empty\",\n        ));\n    }\n    if path.components().any(|component| {\n        matches!(\n            component,\n            Component::ParentDir | Component::Prefix(_) | Component::RootDir\n        )\n    }) && path.is_relative()\n    {\n        return Err(std::io::Error::new(\n            std::io::ErrorKind::InvalidInput,\n            \"managed directory path cannot contain traversal components\",\n        ));\n    }\n    if path.is_absolute() {\n        return Ok(path);","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/session_manager.rs#L94-L130","documentation":"normalize_managed_dir normalizes the directory where the session manager stores its data. An empty PathBuf (no OS string content) cannot name a managed directory, so it is rejected with InvalidInput at construction time. This is a fail-loud config guard: an empty path is always a configuration mistake.","triggerScenarios":"Constructing the session manager via new() (or SessionManager::new-style construction) with a configured directory that resolves to an empty PathBuf — e.g. an unset/empty config field assigned to the managed dir.","commonSituations":"Config file has `sessions_dir = \"\"` or the key omitted and the loader left the raw empty default; an environment variable used for the dir was unset; programmatic construction passed PathBuf::new().","solutions":["Set a concrete directory path in the config (e.g. ~/.local/share/codewhale/sessions) instead of an empty value.","If sourced from an env var, ensure the variable is set before launching.","Check the config-loading layer so an omitted key falls back to the documented default rather than an empty path.","In programmatic use, supply PathBuf::from(\"/valid/dir\") rather than PathBuf::new()."],"exampleFix":"// before\n// config.toml\nsessions_dir = \"\"\n// after\n// config.toml\nsessions_dir = \"/home/user/.local/share/codewhale/sessions\"","handlingStrategy":"validation","validationCode":"let dir = config.sessions_dir.as_deref().filter(|s| !s.is_empty())\n    .ok_or_else(|| anyhow!(\"sessions_dir is required and cannot be empty\"))?;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give every path config key a concrete default instead of an empty fallback.","Fail config validation at load time for empty required paths.","When sourcing from env vars, treat unset as an error, not an empty string."],"tags":["config","path","validation"],"backgroundTag":"empty-required-field","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}