{"record":{"id":"3136fc2035349d8b","repo":"Hmbown/CodeWhale","slug":"skill-name-must-be-a-single-path-safe-segment-got","errorCode":null,"errorMessage":"skill name must be a single path-safe segment (got '{name}')","messagePattern":"skill name must be a single path-safe segment \\(got '(.+?)'\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/skills/install.rs","lineNumber":1549,"sourceCode":"    }\n    for component in path.components() {\n        match component {\n            Component::ParentDir => return false,\n            Component::Prefix(_) | Component::RootDir => return false,\n            _ => {}\n        }\n    }\n    true\n}\n\nfn skill_target_path(name: &str, skills_dir: &Path) -> Result<PathBuf> {\n    let name = validate_skill_name_segment(name)?;\n    Ok(skills_dir.join(name))\n}\n\npub(crate) fn validate_skill_name_segment(name: &str) -> Result<&str> {\n    if name.is_empty() || name.trim() != name || name.chars().any(char::is_whitespace) {\n        bail!(\"skill name must be a single path-safe segment (got '{name}')\");\n    }\n    if name == \".\" || name == \"..\" || name.contains('/') || name.contains('\\\\') {\n        bail!(\"skill name must be a single path-safe segment (got '{name}')\");\n    }\n    let mut components = Path::new(name).components();\n    if !matches!(components.next(), Some(Component::Normal(_))) || components.next().is_some() {\n        bail!(\"skill name must be a single path-safe segment (got '{name}')\");\n    }\n    Ok(name)\n}\n\nfn ensure_target_within_skills_dir(target: &Path, skills_dir: &Path) -> Result<()> {\n    let skills_dir = fs::canonicalize(skills_dir)\n        .with_context(|| format!(\"failed to resolve {}\", skills_dir.display()))?;\n    let target = fs::canonicalize(target)\n        .with_context(|| format!(\"failed to resolve {}\", target.display()))?;\n    if !target.starts_with(&skills_dir) {\n        bail!(","sourceCodeStart":1531,"sourceCodeEnd":1567,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/skills/install.rs#L1531-L1567","documentation":"`validate_skill_name_segment` enforces that a skill name is a single, path-safe path component: non-empty, no surrounding or internal whitespace, not `.`/`..`, no path separators, and exactly one `Normal` component. This prevents skills from escaping the skills directory via crafted names (path traversal) or resolving to surprising locations.","triggerScenarios":"Passing any name with `/`, `\\\\`, leading/trailing whitespace, internal whitespace, `.` or `..`, an empty string, or components like `..`/root prefixes to `uninstall`, `skill_target_path`, `update*`, or `validate_skill_name_segment` itself.","commonSituations":"Names parsed from URLs or registry entries retaining a path suffix (`\"acme/skill\"`); shell-quoting artifacts leaving stray spaces; malicious registry entries attempting `../` traversal; empty name from a failed parse.","solutions":["Sanitize the name: take only the final path segment, trim whitespace, reject separators","Validate the name with `validate_skill_name_segment` before calling install/uninstall/update","Fix the upstream registry entry/URL parsing that produced the unsafe name"],"exampleFix":"// before\nlet name = \"acme/skill\"; // from registry entry\nuninstall(name, &skills_dir)?; // bails\n// after\nlet name = \"acme/skill\".rsplit('/').next().unwrap().trim();\nvalidate_skill_name_segment(name)?;\nuninstall(name, &skills_dir)?;","handlingStrategy":"validation","validationCode":"fn safe_name(n: &str) -> Option<&str> {\n    let n = n.rsplit(['/', '\\\\']).next().unwrap_or(\"\").trim();\n    validate_skill_name_segment(n).ok()\n}","typeGuard":null,"tryCatchPattern":"let name = validate_skill_name_segment(&raw_name)\n    .map_err(|e| anyhow!(\"rejecting skill name: {e}\"))?;","preventionTips":["Validate names parsed from URLs/registries before use","Never accept names containing /, \\\\, .., or whitespace","Call validate_skill_name_segment at the trust boundary"],"tags":["validation","path-safety","security"],"backgroundTag":"path-traversal-blocked","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"}