BoundaryML/baml · error · EngineError
{0}
Error message
{0} What it means
InitFailed wraps a package initialization failure in the bex engine, carrying an opaque description of what went wrong. The library throws it when initializing the VM's package/bootstrap state fails for any reason (missing module, bad bytecode, host setup error). The inner string is the only diagnostic detail; inspect it to find the root cause.
Source
Thrown at baml_language/crates/bex_engine/src/lib.rs:861
CannotConvert { type_name: String },
#[error("Type mismatch: {message}")]
TypeMismatch { message: String },
#[error("Schema inconsistency: {message}")]
SchemaInconsistency { message: String },
#[cfg(feature = "heap_debug")]
#[error("Snapshot not possible for type: {type_name}")]
CannotSnapshot { type_name: String },
#[error("A function call with ID {call_id} is already in progress")]
DuplicateCallId { call_id: CallId },
#[error("Package initialization failed: {0}")]
InitFailed(String),
#[error("{0}")]
Other(String),
}
fn format_vm_internal_error(
err: &bex_vm::errors::VmInternalError,
trace: &[bex_vm::StackFrame],
) -> String {
use std::fmt::Write;
let mut out = bex_vm::format_traceback(
trace
.iter()
.map(|f| (f.file_path.as_str(), f.error_line, f.function_name.as_str())),
);
write!(out, "VM internal error: {err}").unwrap();
out
}
/// Recognize an uncaught `baml.panics.Exit { code }` and pull its `code`View on GitHub (pinned to bd85ce9dee)
Solutions
- Read the wrapped String message to identify the underlying init failure.
- Verify the package/bytecode artifacts exist, are complete, and were built by a compatible compiler version.
- Rebuild the package from source and retry initialization.
- If it persists, capture the message and report it — it may indicate an internal engine bug rather than caller error.
Example fix
// before
let engine = BexEngine::start(config)?;
// after
let engine = match BexEngine::start(config) {
Ok(e) => e,
Err(e @ BexError::InitFailed(msg)) => {
eprintln!("engine init failed: {msg}");
return Err(e);
}
}; Defensive patterns
Strategy: try-catch
Validate before calling
if !std::path::Path::new(&package_path).exists() {
return Err("package artifacts missing before engine init".into());
} Try / catch
match BexEngine::start(config) {
Ok(e) => e,
Err(e) if matches!(e, BexError::InitFailed(_)) => {
log::error!("bex init failed: {e}");
Err(e)
}
Err(e) => Err(e),
} Prevention
- Validate package artifacts exist and are complete before engine start.
- Pin compiler/engine versions so bytecode format matches.
- Log the wrapped InitFailed string for diagnosis.
When it happens
Trigger: Creating or starting a bex VM/engine session whose package initialization step returns an error; the engine converts it into Error::InitFailed(String) via thisDisplay.
Common situations: Loading a program compiled against an incompatible bytecode/module format, corrupted or missing package artifacts, or host-side setup failures (e.g. a module that panics or returns an error during its init routine).
Related errors
- engine is not current with the latest sources; wait for the
- BAML engine is shutting down
- Function call with ID {call_id} not found
- Future with ID {future_id} not found
- Function not found: {name}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/5186808088ede22e.
Report an issue: GitHub.