BoundaryML/baml · error · EngineError
Schema inconsistency: {message}
Error message
Schema inconsistency: {message} What it means
An internal consistency check on schema/type metadata failed: the engine found schema state that violates its own invariants (e.g. a type referenced that the schema does not define consistently). Like VmInternalError this usually indicates a bug rather than user error.
Source
Thrown at baml_language/crates/bex_engine/src/lib.rs:848
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
/// caller clamps into its shell's range (typically 0..=255 on Unix).
#[error("baml.sys.exit({code})")]
Exit { code: i64 },
#[error("Cannot convert object of type {type_name}")]
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,View on GitHub (pinned to bd85ce9dee)
Solutions
- Regenerate/recompile the BAML package schema from source
- Align compiler and engine crate versions
- Remove hand-edits from generated schema artifacts
- Report upstream with the message if it persists on a clean rebuild
Example fix
// before: stale artifacts .baml_cache/ (old schema) // after: clean rebuild rm -rf .baml_cache && baml build
Defensive patterns
Strategy: validation
Validate before calling
// before loading: verify schema artifacts exist and were just generated assert!(pkg.schema_path().exists()); assert_eq!(pkg.compiler_version(), ENGINE_VERSION);
Try / catch
match result {
Err(EngineError::SchemaInconsistency { message }) => {
eprintln!("schema invalid, rebuild: {message}");
rebuild_package()?;
}
Ok(v) => use(v),
Err(e) => handle(e),
} Prevention
- Never hand-edit generated schema files
- Regenerate schema artifacts after every source change
- Keep compiler and engine versions aligned
When it happens
Trigger: Loading or linking a BAML package whose type/schema metadata is inconsistent — duplicate definitions, missing referenced types, or corrupted IR reaching the engine.
Common situations: Stale or partially regenerated compiled schemas; version skew between the compiler that produced the schema and the engine loading it; hand-edited generated files.
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
- Non-regular recursive generic class '{class}' expands from '
- Output definitions '{first}' and '{second}' both render as '
- Type alias definitions for '{rendered_name}' have non-equiva
- pack produced no output at {}
- Type alias not found: {name}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/55c55f99e2bd3210.
Report an issue: GitHub.