vercel/turborepo · critical

path cleaning should preserve UTF-8: {err:?}

Error message

path cleaning should preserve UTF-8: {err:?}

What it means

categorize() takes any &Utf8Path, cleans it with path_clean, and converts the result back to a Utf8PathBuf to decide whether it is absolute (Absolute) or relative (Anchored). The input is already valid UTF-8 and cleaning preserves encoding, so the panic branch is an internal invariant guard, not a user-triggerable condition.

Source

Thrown at crates/turborepo-paths/src/lib.rs:215

    PathValidation {
        well_formed,
        windows_safe,
    }
}

pub enum UnknownPathType {
    Absolute(AbsoluteSystemPathBuf),
    Anchored(AnchoredSystemPathBuf),
}

/// Categorizes a path as either an `AbsoluteSystemPathBuf` or
/// an `AnchoredSystemPathBuf` depending on whether it
/// is absolute or relative.
pub fn categorize(path: &Utf8Path) -> UnknownPathType {
    let path = match Utf8PathBuf::try_from(path_clean::clean(path)) {
        Ok(path) => path,
        Err(err) => panic!("path cleaning should preserve UTF-8: {err:?}"),
    };
    if path.is_absolute() {
        UnknownPathType::Absolute(AbsoluteSystemPathBuf(path))
    } else {
        UnknownPathType::Anchored(AnchoredSystemPathBuf(path))
    }
}

#[cfg(test)]
mod tests {
    use test_case::test_case;

    use crate::{IntoUnix, PathValidation, check_path};

    #[test]
    fn test_into_unix() {
        #[cfg(unix)]
        {

View on GitHub (pinned to f9245100cf)

Solutions

  1. Upgrade turborepo
  2. Ensure downstream code passes only genuine UTF-8 path strings (&str-sourced) into turborepo-paths APIs
  3. File an issue with the path value if reproducible
Defensive patterns

Strategy: fallback

Try / catch

let kind = std::panic::catch_unwind(|| categorize(path));
match kind {
    Ok(UnknownPathType::Absolute(p)) => handle_absolute(p),
    Ok(UnknownPathType::Anchored(p)) => handle_anchored(p),
    Err(_) => fallback_string_classify(path),
}

Prevention

When it happens

Trigger: Only reachable through an internal violation of the UTF-8 invariant (unsafe code or memory corruption); ordinary callers cannot produce it.

Common situations: Would surface as an abort during path categorization inside turbo after an upstream bug.

Related errors


AI-assisted analysis of vercel/turborepo@f9245100cf (2026-08-17). Data as JSON: /api/errors/4fd7dba45948d5e8. Report an issue: GitHub.