BoundaryML/baml · critical · EngineError

VM internal error: {0}

Error message

VM internal error: {0}

What it means

This wraps an internal VM error (bex_vm::errors::VmInternalError) that escaped to the engine boundary, meaning the bytecode interpreter reached a state its own invariants say should be impossible. It is a bug-report signal, not an error the BAML program can cause intentionally. The library throws it when the VM returns an internal error while executing a function call.

Source

Thrown at baml_language/crates/bex_engine/src/lib.rs:819

    #[error("Function call with ID {call_id} not found")]
    FunctionCallNotFound { call_id: CallId },

    #[error("Future with ID {future_id} not found")]
    FutureNotFound { future_id: FutureId },

    #[error("Function not found: {name}")]
    FunctionNotFound { name: String },

    /// Function exists, but its `FunctionKind` is not invokable as an
    /// engine entry point. Only bytecode functions can be called via
    /// [`BexEngine::call_function`] / [`BexEngine::call_function_bound_args`]:
    /// native (`$rust_function`) entries would re-enter the VM through
    /// `YieldToCall` with no bytecode frame to return to. Sysops + builtins
    /// reach their natives from inside a calling bytecode body.
    #[error("Function `{name}` is not invokable as an entry point (kind: {kind})")]
    NotInvokableAsEntry { name: String, kind: String },

    #[error("VM internal error: {0}")]
    VmInternalError(bex_vm::errors::VmInternalError),

    #[error("{}", format_vm_internal_error(source, trace))]
    TracedVmInternalError {
        source: bex_vm::errors::VmInternalError,
        trace: Vec<bex_vm::StackFrame>,
    },

    /// Either a BAML panic or a BAML error value.
    #[error("{}", format_unhandled_throw(value, trace))]
    UnhandledThrow {
        value: Box<BexExternalValue>,
        trace: Vec<bex_vm::StackFrame>,
    },

    /// Clean process-termination request from `baml.sys.exit(code)`.
    /// The caller is expected to honor this as the process exit code.
    /// BAML `int` is `i64`, so the signal carries the full value; the

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Upgrade bex_engine and bex_vm to matching, latest versions
  2. File a bug report with the full error message and the BAML source that triggered it
  3. Try reproducing with a minimal BAML function to isolate the offending construct
  4. Clear cached compiled artifacts and rebuild so stale bytecode is not reused

Example fix

// before: mismatched crate versions
bex_engine = "0.9"
bex_vm = "0.8"
// after: aligned versions
bex_engine = "0.9"
bex_vm = "0.9"
Defensive patterns

Strategy: try-catch

Try / catch

match result {
    Err(EngineError::VmInternalError(e)) => log_bug_report(e),
    Ok(v) => use(v),
    Err(e) => handle(e),
}

Prevention

When it happens

Trigger: Running a BAML function when the VM hits an internal invariant violation (e.g. malformed bytecode, stack corruption, a broken builtin contract). Not reachable through normal user code paths.

Common situations: Developers hit this after using a mismatched engine/VM crate version, after a compiler bug emitted bad bytecode, or when a custom native/sysop misbehaves. Usually surfaced via bug reports.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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