{"record":{"id":"55c55f99e2bd3210","repo":"BoundaryML/baml","slug":"schema-inconsistency-message","errorCode":null,"errorMessage":"Schema inconsistency: {message}","messagePattern":"Schema inconsistency: (.+?)","errorType":"exception","errorClass":"EngineError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_engine/src/lib.rs","lineNumber":848,"sourceCode":"    UnhandledThrow {\n        value: Box<BexExternalValue>,\n        trace: Vec<bex_vm::StackFrame>,\n    },\n\n    /// Clean process-termination request from `baml.sys.exit(code)`.\n    /// The caller is expected to honor this as the process exit code.\n    /// BAML `int` is `i64`, so the signal carries the full value; the\n    /// caller clamps into its shell's range (typically 0..=255 on Unix).\n    #[error(\"baml.sys.exit({code})\")]\n    Exit { code: i64 },\n\n    #[error(\"Cannot convert object of type {type_name}\")]\n    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,","sourceCodeStart":830,"sourceCodeEnd":866,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_engine/src/lib.rs#L830-L866","documentation":"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.","triggerScenarios":"Loading or linking a BAML package whose type/schema metadata is inconsistent — duplicate definitions, missing referenced types, or corrupted IR reaching the engine.","commonSituations":"Stale or partially regenerated compiled schemas; version skew between the compiler that produced the schema and the engine loading it; hand-edited generated files.","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"],"exampleFix":"// before: stale artifacts\n.baml_cache/ (old schema)\n// after: clean rebuild\nrm -rf .baml_cache && baml build","handlingStrategy":"validation","validationCode":"// before loading: verify schema artifacts exist and were just generated\nassert!(pkg.schema_path().exists());\nassert_eq!(pkg.compiler_version(), ENGINE_VERSION);","typeGuard":null,"tryCatchPattern":"match result {\n    Err(EngineError::SchemaInconsistency { message }) => {\n        eprintln!(\"schema invalid, rebuild: {message}\");\n        rebuild_package()?;\n    }\n    Ok(v) => use(v),\n    Err(e) => handle(e),\n}","preventionTips":["Never hand-edit generated schema files","Regenerate schema artifacts after every source change","Keep compiler and engine versions aligned"],"tags":["schema","invariant","baml"],"backgroundTag":"internal-invariant-violation","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"}