BoundaryML/baml · error · VmBamlError

I/O error: {message}

Error message

I/O error: {message}

What it means

An error value from the BAML standard library, mapping to the `baml.errors.Io` class. It represents a generic input/output failure from a stdlib operation that touches the outside world (files, streams, subprocess I/O, etc.), with the underlying reason in `message`.

Source

Thrown at baml_language/crates/bex_vm_types/src/errors.rs:119

    /// echo).
    #[error("host contract violation: {message} [class={class_name:?}, lang={language:?}]")]
    HostContractViolation {
        message: String,
        class_name: Option<String>,
        language: Option<String>,
    },
}

/// An error value from the BAML standard library. Maps 1:1 to a `baml.errors.*` class.
#[derive(Debug, Error, PartialEq, Clone)]
pub enum VmBamlError {
    #[error("invalid argument: {message}")]
    InvalidArgument { message: String },

    #[error("parse error: {message}")]
    ParseError { message: String },

    #[error("I/O error: {message}")]
    Io { message: String },

    #[error("timeout: {message}")]
    Timeout {
        message: String,
        duration_ms: Option<i64>,
    },

    #[error("unsupported: {message}")]
    Unsupported { message: String },

    #[error("access error: {message}")]
    AccessError { message: String },

    #[error("render prompt: {message}")]
    RenderPrompt { message: String },

    #[error("LLM client error: {message}")]

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Verify paths and that the resource exists/permissions allow access before the I/O call.
  2. Catch `baml.errors.Io` and surface a user-friendly message or fallback input source.
  3. Check the environment (working directory, mounts, file permissions) where the program runs.
  4. Inspect the wrapped `message` to identify the underlying OS error and address it directly.

Example fix

// before
let raw = fs.read("prompts/p.txt");
// after
let raw = if fs.exists("prompts/p.txt") {
  fs.read("prompts/p.txt")
} else {
  fs.read("prompts/default.txt")
};
Defensive patterns

Strategy: try-catch

Validate before calling

// BAML: check resource presence before I/O
if !fs.exists(path) {
  return err("missing input file: " + path);
}

Try / catch

try {
  let raw = fs.read(path);
} catch e: baml.errors.Io {
  return fallback_input() ?? rethrow_with_context(e.message);
}

Prevention

When it happens

Trigger: A stdlib I/O call fails at the OS/host level: missing file or directory, closed stream, device error, or a host-reported I/O exception propagated into the VM.

Common situations: Reading a prompt file that doesn't exist at the given path; running in a container where the working directory or mounted volume differs; a stream being closed by the other side mid-operation.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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