BoundaryML/baml · error
internal error: cannot convert value
Error message
internal error: cannot convert value {value} to VM value: enum '{enm}' not found in VM objects What it means
The enum name resolved correctly, but the object at the mapped index in the VM object table is not an Enum object. The runtime considers this an internal invariant violation that should be unreachable in normal operation.
Solutions
- Report the bug to the BAML repository with reproduction and full error text
- Align all BAML crate/client versions to the same release
- Clean and rebuild the runtime artifacts
Defensive patterns
Strategy: try-catch
Try / catch
Err(e) if e.to_string().starts_with("internal error:") => { log::error!("baml bug: {e}"); panic!() } Prevention
- Align baml-* crate versions
- Clean rebuild after upgrades
- Report upstream with reproduction
When it happens
Trigger: VM object table inconsistent with resolved enum indices — indicates a BAML runtime bug or mismatched runtime/compiler artifacts.
Common situations: Mixing versions of baml-runtime and baml-compiler; patched or custom VM builds; otherwise a bug to report upstream.
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/ae47a35f4b2719f0.
Report an issue: GitHub.
Appendix: source
Thrown at engine/baml-runtime/src/async_vm_runtime.rs:1319
for v in ordered_field_values {
vm_fields_layout.push(try_vm_value_from_baml_value(
vm,
resolved_class_names,
resolved_enums_names,
v,
)?);
}
Ok(vm.alloc_instance(*class_index, vm_fields_layout))
}
BamlValue::Enum(enm, variant) => {
let Some(enum_index) = resolved_enums_names.get(enm) else {
anyhow::bail!("cannot convert value {value} to VM value: enum '{enm}' not found");
};
let baml_vm::Object::Enum(enm) = &vm.objects[*enum_index] else {
anyhow::bail!(
"internal error: cannot convert value {value} to VM value: enum '{enm}' not found in VM objects"
);
};
let Some(variant_index) = enm.variant_names.iter().position(|v| v == variant) else {
anyhow::bail!(
"cannot convert value {value} to VM value: enum '{enm}' has no variant '{variant}'"
);
};
Ok(vm.alloc_variant(*enum_index, variant_index))
}
BamlValue::Media(media) => Ok(vm.alloc_media(media.clone())),
}
}
fn try_vm_value_from_function_result(View on GitHub (pinned to bd85ce9dee)