{"record":{"id":"9504e7bdb693463d","repo":"Hmbown/CodeWhale","slug":"refusing-to-mutate-through-non-directory-codewhale","errorCode":null,"errorMessage":"refusing to mutate through non-directory CodeWhale skills path component {}","messagePattern":"refusing to mutate through non-directory CodeWhale skills path component (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/skills/mutation.rs","lineNumber":154,"sourceCode":"    match target {\n        SkillTargetScope::Project => Ok(workspace),\n        SkillTargetScope::Global => home.context(\"global skill mutations require a home directory\"),\n    }\n}\n\n/// Return whether `path` is an existing real directory, rejecting links and\n/// non-directory components. `symlink_metadata` is intentional: following a\n/// link before checking it would turn a lexical CodeWhale-owned root into an\n/// attacker-selected write target.\nfn checked_real_directory(path: &Path) -> Result<bool> {\n    match fs::symlink_metadata(path) {\n        Ok(meta) if meta.file_type().is_symlink() => {\n            bail!(\n                \"refusing to mutate symlinked CodeWhale skills path component {}\",\n                path.display()\n            )\n        }\n        Ok(meta) if !meta.is_dir() => bail!(\n            \"refusing to mutate through non-directory CodeWhale skills path component {}\",\n            path.display()\n        ),\n        Ok(_) => Ok(true),\n        Err(err) if err.kind() == ErrorKind::NotFound => Ok(false),\n        Err(err) => Err(err).with_context(|| format!(\"failed to inspect {}\", path.display())),\n    }\n}\n\n/// Validate the complete owned-root chain without following a symlink in the\n/// workspace/home anchor, `.codewhale`, or `skills` component.\nfn validate_owned_target_chain(\n    anchor: &Path,\n    skills_dir: &Path,\n    require_existing: bool,\n) -> Result<()> {\n    let expected = anchor.join(\".codewhale\").join(\"skills\");\n    if skills_dir != expected {","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/skills/mutation.rs#L136-L172","documentation":"checked_real_directory found that a component of the owned skills path exists but is not a directory (a file, or another non-directory entry) and is not a symlink. Writes cannot proceed because the expected directory component is occupied by a non-directory; the offending path component is the input at fault. Generic validation guard used by validate_owned_target_chain, create_owned_directory, prepare_owned_target, and validate_owned_child.","triggerScenarios":"Thrown at crates/tui/src/skills/mutation.rs:154 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the reported path component and remove or rename the file occupying it","Let CodeWhale recreate the .codewhale/skills directory structure after clearing the obstruction"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}