{"record":{"id":"d99b31f6e43c0d83","repo":"BoundaryML/baml","slug":"invalid-vfs-path-0","errorCode":null,"errorMessage":"invalid VFS path: {0}","messagePattern":"invalid VFS path: (.+?)","errorType":"exception","errorClass":"FsPathError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_path/src/lib.rs","lineNumber":42,"sourceCode":"    }\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(());\n    }\n\n    let invalid = !path.starts_with('/')\n        || path.ends_with('/')\n        || path\n            .split('/')","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_path/src/lib.rs#L24-L60","documentation":"FsPathError::InvalidVfsPath is thrown by the baml_path crate when a path string cannot be interpreted as a valid virtual filesystem (VFS) path. The FsPathError enum also covers non-Unicode native paths and unsupported native path prefixes (like Windows verbatim prefixes), and every variant is converted into a vfs::VfsError via the From impl. It means the caller supplied a path that does not map cleanly onto the VFS abstraction.","triggerScenarios":"Calling a baml_path API with a malformed or empty path string, a path with an unsupported native prefix, or a path containing components the VFS cannot represent; the resulting FsPathError is propagated (usually converted to vfs::VfsError::Other) as 'invalid VFS path: {path}'.","commonSituations":"Using Windows verbatim or UNC prefixes (\\\\?\\C\\...) that the VFS layer rejects, passing an empty or relative path where an absolute canonical path is required, or constructing paths programmatically with stray separators/invalid characters on cross-platform builds.","solutions":["Print and inspect the exact offending path embedded in the error message","Normalize the path (e.g. std::fs::canonicalize or path cleaning) before passing it to the VFS API","Strip unsupported prefixes (e.g. Windows verbatim \\\\?\\) and use plain absolute paths","Ensure paths are valid UTF-8; reject or convert OsStr paths that are not Unicode","Validate the path against the target platform's rules before calling the library"],"exampleFix":"// before\nlet p = std::path::Path::new(\"\\\\\\\\?\\\\C:\\\\tmp\\\\baml\");\nvfs_root.join(p);\n// after\nlet p = std::path::PathBuf::from(\"C:\\\\tmp\\\\baml\");\nlet canonical = std::fs::canonicalize(&p)?;\nvfs_root.join(canonical);","handlingStrategy":"validation","validationCode":"fn is_vfs_safe(p: &Path) -> bool {\n    p.is_absolute()\n        && p.to_str().map(|s| !s.is_empty() && !s.contains(\"\\\\\\\\?!\\\\\\\\\")).unwrap_or(false)\n}","typeGuard":"fn valid_vfs_path(p: &Path) -> Option<&str> { p.to_str().filter(|s| !s.is_empty()) }","tryCatchPattern":"match vfs_op(path) {\n    Err(e) if e.to_string().starts_with(\"invalid VFS path\") => warn!(\"bad path: {path:?}\"),\n    Err(e) => return Err(e),\n    Ok(v) => Ok(v),\n}","preventionTips":["Always canonicalize paths before handing them to the VFS","Reject empty and relative paths at your CLI/API boundary","Normalize Windows prefixes (\\\\?\\, UNC) to plain absolute paths early","Ensure all paths round-trip through valid UTF-8"],"tags":["path","vfs","rust"],"backgroundTag":"invalid-argument-format","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"}