{"record":{"id":"5186808088ede22e","repo":"BoundaryML/baml","slug":"0-518680","errorCode":null,"errorMessage":"{0}","messagePattern":"\\{0\\}","errorType":"exception","errorClass":"EngineError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_engine/src/lib.rs","lineNumber":861,"sourceCode":"    CannotConvert { type_name: String },\n\n    #[error(\"Type mismatch: {message}\")]\n    TypeMismatch { message: String },\n\n    #[error(\"Schema inconsistency: {message}\")]\n    SchemaInconsistency { message: String },\n\n    #[cfg(feature = \"heap_debug\")]\n    #[error(\"Snapshot not possible for type: {type_name}\")]\n    CannotSnapshot { type_name: String },\n\n    #[error(\"A function call with ID {call_id} is already in progress\")]\n    DuplicateCallId { call_id: CallId },\n\n    #[error(\"Package initialization failed: {0}\")]\n    InitFailed(String),\n\n    #[error(\"{0}\")]\n    Other(String),\n}\n\nfn format_vm_internal_error(\n    err: &bex_vm::errors::VmInternalError,\n    trace: &[bex_vm::StackFrame],\n) -> String {\n    use std::fmt::Write;\n    let mut out = bex_vm::format_traceback(\n        trace\n            .iter()\n            .map(|f| (f.file_path.as_str(), f.error_line, f.function_name.as_str())),\n    );\n    write!(out, \"VM internal error: {err}\").unwrap();\n    out\n}\n\n/// Recognize an uncaught `baml.panics.Exit { code }` and pull its `code`","sourceCodeStart":843,"sourceCodeEnd":879,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_engine/src/lib.rs#L843-L879","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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."],"exampleFix":"// before\nlet engine = BexEngine::start(config)?;\n// after\nlet engine = match BexEngine::start(config) {\n    Ok(e) => e,\n    Err(e @ BexError::InitFailed(msg)) => {\n        eprintln!(\"engine init failed: {msg}\");\n        return Err(e);\n    }\n};","handlingStrategy":"try-catch","validationCode":"if !std::path::Path::new(&package_path).exists() {\n    return Err(\"package artifacts missing before engine init\".into());\n}","typeGuard":null,"tryCatchPattern":"match BexEngine::start(config) {\n    Ok(e) => e,\n    Err(e) if matches!(e, BexError::InitFailed(_)) => {\n        log::error!(\"bex init failed: {e}\");\n        Err(e)\n    }\n    Err(e) => Err(e),\n}","preventionTips":["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."],"tags":["initialization","engine","rust"],"backgroundTag":"module-init-failed","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"}