{"record":{"id":"36e9728c7a7e51cb","repo":"BoundaryML/baml","slug":"native-path-is-not-absolute-0","errorCode":null,"errorMessage":"native path is not absolute: {0}","messagePattern":"native path is not absolute: (.+?)","errorType":"exception","errorClass":"FsPathError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_path/src/lib.rs","lineNumber":33,"sourceCode":"\nimpl VfsPathBuf {\n    pub fn new(path: String) -> Result<Self, FsPathError> {\n        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","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_path/src/lib.rs#L15-L51","documentation":"FsPathError::NotAbsolute is returned by baml_path when a native filesystem path that must be absolute is instead relative. The VFS layer requires absolute native paths to unambiguously map between VFS URIs and on-disk locations.","triggerScenarios":"Calling a baml_path conversion API (native->VFS mapping) with a relative path like \"src/foo.baml\" or one built from a relative working directory; passing a path captured before a chdir.","commonSituations":"Using std::env::current_dir() results carelessly; constructing paths from CLI args that were given relative; tests running with a different cwd than production; config files storing relative paths.","solutions":["Convert the path to absolute before use, e.g. std::fs::canonicalize(path) or std::env::current_dir()?.join(rel).","Anchor user-supplied paths against an explicit project root at the boundary.","Update stored config to hold absolute paths.","Add a debug_assert!(p.is_absolute()) at call sites that require absolute input to fail early."],"exampleFix":"// before\nlet vfs = FsPath::new(\"src/main.baml\").to_vfs()?;\n\n// after\nlet abs = std::env::current_dir()?.join(\"src/main.baml\");\nlet vfs = FsPath::new(abs).to_vfs()?;","handlingStrategy":"validation","validationCode":"fn ensure_absolute(p: &std::path::Path) -> bool { p.is_absolute() }\n// call before conversion\nif !ensure_absolute(&path) {\n    let path = std::fs::canonicalize(&path)?;\n}","typeGuard":"fn is_absolute_native(p: &std::path::Path) -> bool {\n    p.is_absolute()\n}","tryCatchPattern":null,"preventionTips":["Canonicalize or join against an explicit root at the CLI/config boundary","Store absolute paths in configuration files","Add debug_assert!(path.is_absolute()) in conversion call sites"],"tags":["rust","filesystem","path"],"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"}