{"record":{"id":"4fd7dba45948d5e8","repo":"vercel/turborepo","slug":"path-cleaning-should-preserve-utf-8-err","errorCode":null,"errorMessage":"path cleaning should preserve UTF-8: {err:?}","messagePattern":"path cleaning should preserve UTF-8: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/turborepo-paths/src/lib.rs","lineNumber":215,"sourceCode":"\n    PathValidation {\n        well_formed,\n        windows_safe,\n    }\n}\n\npub enum UnknownPathType {\n    Absolute(AbsoluteSystemPathBuf),\n    Anchored(AnchoredSystemPathBuf),\n}\n\n/// Categorizes a path as either an `AbsoluteSystemPathBuf` or\n/// an `AnchoredSystemPathBuf` depending on whether it\n/// is absolute or relative.\npub fn categorize(path: &Utf8Path) -> UnknownPathType {\n    let path = match Utf8PathBuf::try_from(path_clean::clean(path)) {\n        Ok(path) => path,\n        Err(err) => panic!(\"path cleaning should preserve UTF-8: {err:?}\"),\n    };\n    if path.is_absolute() {\n        UnknownPathType::Absolute(AbsoluteSystemPathBuf(path))\n    } else {\n        UnknownPathType::Anchored(AnchoredSystemPathBuf(path))\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use test_case::test_case;\n\n    use crate::{IntoUnix, PathValidation, check_path};\n\n    #[test]\n    fn test_into_unix() {\n        #[cfg(unix)]\n        {","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/vercel/turborepo/blob/f9245100cf0d31d96628804ead485f6bf226e55a/crates/turborepo-paths/src/lib.rs#L197-L233","documentation":"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.","triggerScenarios":"Only reachable through an internal violation of the UTF-8 invariant (unsafe code or memory corruption); ordinary callers cannot produce it.","commonSituations":"Would surface as an abort during path categorization inside turbo after an upstream bug.","solutions":["Upgrade turborepo","Ensure downstream code passes only genuine UTF-8 path strings (&str-sourced) into turborepo-paths APIs","File an issue with the path value if reproducible"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"let kind = std::panic::catch_unwind(|| categorize(path));\nmatch kind {\n    Ok(UnknownPathType::Absolute(p)) => handle_absolute(p),\n    Ok(UnknownPathType::Anchored(p)) => handle_anchored(p),\n    Err(_) => fallback_string_classify(path),\n}","preventionTips":["Ensure all paths entering your application originate from UTF-8 sources (&str, Utf8PathBuf)","Wrap turborepo-paths usage in a subprocess if a panic would be fatal to your host process"],"tags":["rust","panic","path","invariant","utf8"],"backgroundTag":"path-invariant-panic","analyzedSha":"f9245100cf0d31d96628804ead485f6bf226e55a","analyzedAt":"2026-08-17T10:46:15.696Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}