BoundaryML/baml · error
cannot convert value {value} to VM value: class '{name}' not
Error message
cannot convert value {value} to VM value: class '{name}' not found What it means
When converting a BamlValue::Class back into a VM value after a function call, the runtime looks up the class name among the resolved class definitions of the function. This error means the class name on the value has no matching class in the function's resolved classes, so the value cannot be materialized in the VM.
Source
Thrown at engine/baml-runtime/src/async_vm_runtime.rs:1280
for (k, v) in map {
vm_map.insert(
k.to_owned(),
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);
}View on GitHub (pinned to bd85ce9dee)
Solutions
- Regenerate the BAML client so class names match the current .baml schema
- Check that the class name in the value exactly matches a class declared in the .baml files (case-sensitive)
- Ensure nested fields' class types are also declared in the same .baml project
Defensive patterns
Strategy: validation
Validate before calling
// before calling, ensure class name exists in schema
assert classes_in_baml_project().contains("MyClass") Type guard
fn class_name_known(name: &str, resolved: &HashMap<String, usize>) -> bool { resolved.contains_key(name) } Try / catch
match try_vm_value_from_baml_value(...) { Err(e) if e.to_string().contains("class '") => { /* regenerate client / fix schema */ }, ... } Prevention
- Regenerate clients after every .baml schema edit
- Keep class names in code and .baml in sync
- Avoid passing values across functions with different resolved class sets
When it happens
Trigger: A function result (or nested value) carries a class name that is not part of the classes resolved for that function — e.g. the class was renamed/deleted in the .baml files, or the value came from a different runtime/function context.
Common situations: Renaming a BAML class without updating code that produces BamlValue::Class with the old name; passing values between functions with different resolved-class sets; stale generated clients after schema edits.
Related errors
- failed to serialize BAML bytecode: {e}
- Unknown class: {0}
- unknown method '{}' at {:?}, should have been caught during
- Could not unify Class {} with {:?}
- Internal error occurred while resolving repr of field {:?}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/04c11bea193abb1b.
Report an issue: GitHub.