{"record":{"id":"d79c699ea8054763","repo":"vercel/turborepo","slug":"clean-should-produce-valid-utf-8-err","errorCode":null,"errorMessage":"clean should produce valid UTF-8: {err:?}","messagePattern":"clean should produce valid UTF-8: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/turborepo-paths/src/absolute_system_path_buf.rs","lineNumber":94,"sourceCode":"    }\n\n    /// Takes in a system path of unknown type. If it's absolute, returns the\n    /// path, If it's relative, appends it to the base after cleaning it.\n    pub fn from_unknown(base: &AbsoluteSystemPath, unknown: impl Into<Utf8PathBuf>) -> Self {\n        // we have an absolute system path and an unknown kind of system path.\n        let unknown: Utf8PathBuf = unknown.into();\n        if unknown.is_absolute() {\n            Self(unknown)\n        } else {\n            let path = match base\n                .as_path()\n                .join(unknown)\n                .as_std_path()\n                .clean()\n                .try_into()\n            {\n                Ok(path) => path,\n                Err(err) => panic!(\"clean should produce valid UTF-8: {err:?}\"),\n            };\n            Self(path)\n        }\n    }\n\n    pub fn from_cwd(unknown: impl Into<Utf8PathBuf>) -> Result<Self, PathError> {\n        let cwd = Self::cwd()?;\n        Ok(Self::from_unknown(&cwd, unknown))\n    }\n\n    pub fn cwd() -> Result<Self, PathError> {\n        // TODO(errors): Unwrap current_dir()\n        Ok(Self(Utf8PathBuf::try_from(std::env::current_dir()?)?))\n    }\n\n    /// Anchors `path` at `self`.\n    ///\n    /// # Arguments","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/vercel/turborepo/blob/f9245100cf0d31d96628804ead485f6bf226e55a/crates/turborepo-paths/src/absolute_system_path_buf.rs#L76-L112","documentation":"AbsoluteSystemPathBuf::from_unknown resolves a possibly-relative path against a base directory, cleans it, and converts the cleaned std Path into a Utf8PathBuf. Inputs are already Utf8PathBuf (valid UTF-8 by construction) and path cleaning preserves encoding, so the \"clean should produce valid UTF-8\" panic is unreachable absent an internal bug.","triggerScenarios":"No legitimate trigger; would require the UTF-8 invariant of the types to be broken already (unsafe construction or memory corruption).","commonSituations":"Not observed in practice; would surface as an abort during path resolution inside turbo.","solutions":["Upgrade turborepo","Prefer checked constructors (from_cwd, try_from) over any unsafe/unchecked creation of these path types","Report a reproduction if it persists"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"let resolved = std::panic::catch_unwind(|| {\n    AbsoluteSystemPathBuf::from_unknown(&base, relative)\n});\nlet path = resolved.unwrap_or_else(|_| AbsoluteSystemPathBuf::from(base.join(relative)));","preventionTips":["Derive paths from from_cwd()/try_from rather than transmute or unchecked From impls","Validate external input is UTF-8 (&str) before it enters any turborepo-paths type"],"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"}