BoundaryML/baml · error · FsPathError

unsupported native path prefix: {0}

Error message

unsupported native path prefix: {0}

What it means

FsPathError::UnsupportedPrefix is returned when a native path uses a prefix form baml_path does not support, e.g. Windows verbatim (\\?\C:\...) or device namespace (\\.\) prefixes. Such paths cannot be mapped into the VFS path scheme.

Source

Thrown at baml_language/crates/baml_path/src/lib.rs:39

    pub fn as_str(&self) -> &str {
        &self.0
    }

    pub fn into_string(self) -> String {
        self.0
    }
}

#[derive(Debug, thiserror::Error)]
pub enum FsPathError {
    #[error("native path is not absolute: {0}")]
    NotAbsolute(PathBuf),

    #[error("native path is not valid Unicode: {0:?}")]
    NonUnicode(PathBuf),

    #[error("unsupported native path prefix: {0}")]
    UnsupportedPrefix(PathBuf),

    #[error("invalid VFS path: {0}")]
    InvalidVfsPath(String),
}

impl From<FsPathError> for vfs::VfsError {
    fn from(error: FsPathError) -> Self {
        vfs::VfsError::from(vfs::error::VfsErrorKind::Other(error.to_string()))
    }
}

fn validate_vfs_path(path: &str) -> Result<(), FsPathError> {
    if path == "/" {
        return Ok(());
    }

    let invalid = !path.starts_with('/')

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Strip the \\?\ verbatim prefix before conversion (or use the dunce crate's canonicalize which avoids verbatim form).
  2. Use a normal drive-letter path (C:\project\file.baml) instead of a device/namespace path.
  3. Don't point the project at UNC/network shares; copy it to a local drive path.
  4. Normalize the path with a helper that removes unsupported prefixes at the boundary.

Example fix

// before
let p = std::fs::canonicalize(r"C:\proj\main.baml")?; // \\?\C:\proj\main.baml

// after
let p = dunce::canonicalize(r"C:\proj\main.baml")?; // C:\proj\main.baml
Defensive patterns

Strategy: validation

Validate before calling

fn has_unsupported_prefix(p: &std::path::Path) -> bool {
    let s = p.as_os_str().to_string_lossy();
    s.starts_with("\\\\?\\") || s.starts_with("\\\\.\\")
}
// strip or reject before conversion

Type guard

fn is_plain_windows_path(p: &std::path::Path) -> bool {
    let s = p.as_os_str().to_string_lossy();
    !s.starts_with("\\\\?\\") && !s.starts_with("\\\\.\\")
}

Prevention

When it happens

Trigger: On Windows, passing paths produced by dunce-less canonicalization that yield \\?\ verbatim form, or UNC/device paths (\\.\pipe\..., \\?\UNC\server\share) into native->VFS conversion.

Common situations: Using std::fs::canonicalize on Windows (returns \\?\ prefixed paths) before handing the result to baml_path; working with network shares or named pipes; junctions resolved to verbatim form.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/70b8f61467783a78. Report an issue: GitHub.