{"record":{"id":"0674dc398ddd08aa","repo":"BoundaryML/baml","slug":"native-path-is-not-valid-unicode-0","errorCode":null,"errorMessage":"native path is not valid Unicode: {0:?}","messagePattern":"native path is not valid Unicode: (.+?)","errorType":"exception","errorClass":"FsPathError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_path/src/lib.rs","lineNumber":36,"sourceCode":"        validate_vfs_path(&path)?;\n        Ok(Self(path))\n    }\n\n    pub fn as_str(&self) -> &str {\n        &self.0\n    }\n\n    pub fn into_string(self) -> String {\n        self.0\n    }\n}\n\n#[derive(Debug, thiserror::Error)]\npub enum FsPathError {\n    #[error(\"native path is not absolute: {0}\")]\n    NotAbsolute(PathBuf),\n\n    #[error(\"native path is not valid Unicode: {0:?}\")]\n    NonUnicode(PathBuf),\n\n    #[error(\"unsupported native path prefix: {0}\")]\n    UnsupportedPrefix(PathBuf),\n\n    #[error(\"invalid VFS path: {0}\")]\n    InvalidVfsPath(String),\n}\n\nimpl From<FsPathError> for vfs::VfsError {\n    fn from(error: FsPathError) -> Self {\n        vfs::VfsError::from(vfs::error::VfsErrorKind::Other(error.to_string()))\n    }\n}\n\nfn validate_vfs_path(path: &str) -> Result<(), FsPathError> {\n    if path == \"/\" {\n        return Ok(());","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_path/src/lib.rs#L18-L54","documentation":"FsPathError::NonUnicode is returned when a native path contains bytes that cannot be decoded as valid UTF-8 (common on Linux where paths are arbitrary bytes). baml_path requires Unicode-native paths because VFS URIs are string-based.","triggerScenarios":"Converting a PathBuf whose OS string contains invalid UTF-8 (e.g. a filename with raw 0x80-0xFF bytes from another encoding) into a VFS path; files created by tools using legacy locale encodings.","commonSituations":"Files with names in Latin-1/Shift-JIS created by older tools; filenames with mojibake after a bad unzip; projects synced from systems with non-UTF-8 filesystem encodings.","solutions":["Rename the offending file/directory to a valid UTF-8 name (e.g. using convmv).","Recreate the file with a Unicode-safe name and restore its contents.","Exclude non-UTF-8 paths from the project/workspace indexing.","Find offenders with: find . | grep -P '[\\x80-\\xFF]' (after confirming encoding)."],"exampleFix":"// before\nconvmv -f latin1 -t utf-8 --notest badname.baml  // if needed\n// after renaming\nlet vfs = FsPath::new(path).to_vfs()?; // succeeds","handlingStrategy":"validation","validationCode":"fn is_utf8_path(p: &std::path::Path) -> bool {\n    std::str::from_utf8(\n        std::os::unix::ffi::OsStrExt::as_bytes(p.as_os_str())\n    ).is_ok()\n}","typeGuard":"fn valid_unicode_path(p: &std::path::Path) -> Option<&str> {\n    p.to_str()\n}","tryCatchPattern":null,"preventionTips":["Name files with ASCII/UTF-8 characters only","Audit projects for non-UTF-8 filenames (convmv/find) before indexing","Skip non-UTF-8 paths during workspace traversal"],"tags":["rust","filesystem","encoding","unicode"],"backgroundTag":"invalid-argument-value","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}