Hmbown/CodeWhale · error
skill name must be a single path-safe segment
Error message
skill name must be a single path-safe segment (got '{name}') What it means
`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.
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
Example fix
// before
let name = "acme/skill"; // from registry entry
uninstall(name, &skills_dir)?; // bails
// after
let name = "acme/skill".rsplit('/').next().unwrap().trim();
validate_skill_name_segment(name)?;
uninstall(name, &skills_dir)?; Defensive patterns
Strategy: validation
Validate before calling
fn safe_name(n: &str) -> Option<&str> {
let n = n.rsplit(['/', '\\']).next().unwrap_or("").trim();
validate_skill_name_segment(n).ok()
} Try / catch
let name = validate_skill_name_segment(&raw_name)
.map_err(|e| anyhow!("rejecting skill name: {e}"))?; Prevention
- Validate names parsed from URLs/registries before use
- Never accept names containing /, \\, .., or whitespace
- Call validate_skill_name_segment at the trust boundary
When it happens
Trigger: 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.
Common situations: 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.
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
- append_allow_rules only accepts action = "allow"
- artifact id and extension must contain safe ASCII characters
- Codewhale credentials directory has an unsupported component
- Codewhale terminal receipt exceeded its string bound
- CodewhalePet/1
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/3136fc2035349d8b.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/skills/install.rs:1549
}
for component in path.components() {
match component {
Component::ParentDir => return false,
Component::Prefix(_) | Component::RootDir => return false,
_ => {}
}
}
true
}
fn skill_target_path(name: &str, skills_dir: &Path) -> Result<PathBuf> {
let name = validate_skill_name_segment(name)?;
Ok(skills_dir.join(name))
}
pub(crate) fn validate_skill_name_segment(name: &str) -> Result<&str> {
if name.is_empty() || name.trim() != name || name.chars().any(char::is_whitespace) {
bail!("skill name must be a single path-safe segment (got '{name}')");
}
if name == "." || name == ".." || name.contains('/') || name.contains('\\') {
bail!("skill name must be a single path-safe segment (got '{name}')");
}
let mut components = Path::new(name).components();
if !matches!(components.next(), Some(Component::Normal(_))) || components.next().is_some() {
bail!("skill name must be a single path-safe segment (got '{name}')");
}
Ok(name)
}
fn ensure_target_within_skills_dir(target: &Path, skills_dir: &Path) -> Result<()> {
let skills_dir = fs::canonicalize(skills_dir)
.with_context(|| format!("failed to resolve {}", skills_dir.display()))?;
let target = fs::canonicalize(target)
.with_context(|| format!("failed to resolve {}", target.display()))?;
if !target.starts_with(&skills_dir) {
bail!(View on GitHub (pinned to 73e0f67d83)