BoundaryML/baml · error
internal error: cannot convert value
Error message
internal error: cannot convert value {value} to VM value: class '{name}' not found in VM objects What it means
A continuation of the class lookup: the class name WAS found in resolved_class_names, but the object stored at that index in the VM is not a Class object. The runtime treats this as an internal invariant violation, since the index mapping and VM object table should be consistent.
Solutions
- Report the bug to the BAML repository with the full error and reproduction steps
- Ensure baml-runtime, baml-compiler, and generated client versions are all from the same release
- Rebuild/reinstall the BAML runtime to rule out stale artifacts
Defensive patterns
Strategy: try-catch
Try / catch
// treat as internal bug: log full error and report upstream
Err(e) if e.to_string().starts_with("internal error:") => { log::error!("baml bug: {e}"); panic!() } Prevention
- Use matching versions of all baml-* crates
- Rebuild artifacts after upgrades
- Report occurrences upstream with reproduction
When it happens
Trigger: VM object table corrupted or mismatched with resolved class indices — this should be unreachable in normal use and indicates a bug in the BAML runtime (or custom/patched VM usage).
Common situations: Hitting it in practice usually means running a mismatched mix of runtime/compiler versions, or a genuine BAML bug; report it with a reproduction.
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
- internal error
- internal error: cannot convert value
- ======================================== BAML Internal…
- cannot convert value
- cannot convert value
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/09bdb435954f68c8.
Report an issue: GitHub.
Appendix: source
Thrown at engine/baml-runtime/src/async_vm_runtime.rs:1284
try_vm_value_from_baml_value(
vm,
resolved_class_names,
resolved_enums_names,
v,
)?,
);
}
Ok(vm.alloc_map(vm_map))
}
BamlValue::Class(name, fields) => {
let Some(class_index) = resolved_class_names.get(name) else {
anyhow::bail!("cannot convert value {value} to VM value: class '{name}' not found");
};
let baml_vm::Object::Class(class) = &vm.objects[*class_index] else {
anyhow::bail!(
"internal error: cannot convert value {value} to VM value: class '{name}' not found in VM objects"
);
};
let mut ordered_field_values = Vec::new();
for field_name in &class.field_names {
let Some(value) = fields.get(field_name) else {
anyhow::bail!(
"cannot convert value {value} to VM value: class '{name}' has no field '{field_name}'"
);
};
ordered_field_values.push(value);
}
let mut vm_fields_layout = Vec::new();
for v in ordered_field_values {
vm_fields_layout.push(try_vm_value_from_baml_value(View on GitHub (pinned to bd85ce9dee)