BoundaryML/baml · error · anyhow::Error
Unsupported object type for testing
Error message
Unsupported object type for testing: {:?} What it means
from_vm_object only maps a fixed subset of VmObject kinds (Function, Class, Enum, and earlier handled kinds) into the test Object representation. Any other kind reaches the catch-all arm and is rejected. It exists to make unsupported conversions explicit rather than silently dropping them.
Solutions
- Extend the match in from_vm_object to explicitly handle the new VmObject kind
- If instances are needed for tests, add an arm like `VmObject::Instance(i) => Ok(Object::Instance(...))`
- Otherwise filter out unsupported kinds before calling from_vm_object
Example fix
// before
_ => anyhow::bail!("Unsupported object type for testing: {:?}", obj),
// after
VmObject::Instance(inst) => Ok(Object::Instance(Instance {
class: inst.class.name.clone(),
})),
_ => anyhow::bail!("Unsupported object type for testing: {:?}", obj), Defensive patterns
Strategy: type-guard
Validate before calling
fn is_test_convertible(obj: &VmObject) -> bool {
matches!(obj, VmObject::Function(_) | VmObject::Class(_) | VmObject::Enum(_) | VmObject::Variant(_))
} Type guard
matches!(obj, VmObject::Function(_) | VmObject::Class(_) | VmObject::Enum(_))
Try / catch
match Object::from_vm_object(&vm, obj) { Ok(o) => o, Err(e) => { log::debug!("skipping unconvertible object: {e}"); continue; } } Prevention
- When adding a VmObject variant, search for exhaustive matches on VmObject and update them
- Use #[non_exhaustive]-style discipline and compile-time match checks to catch missing arms
- Filter unsupported kinds before conversion in test helpers
When it happens
Trigger: Calling from_vm_object with a VmObject that is not one of the explicitly handled kinds (e.g. Instance, Variant, raw/primitive objects held differently), so it falls into the `_ =>` arm.
Common situations: Adding a new VmObject variant to the VM and forgetting to extend the match in test.rs; tests serializing watch payloads that contain instance objects.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- AWS Bedrock modular streaming is not supported. Use…
- AWS Bedrock only supports text system blocks, but got
- baml.panics.AssertionFailed
- baml.panics.Cancelled
- baml.panics.DivisionByZero
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/4d3aaf7adff8c594.
Report an issue: GitHub.
Appendix: source
Thrown at engine/baml-vm/src/test.rs:136
let VmObject::Enum(vm_enum) = &vm.objects[variant.enm] else {
anyhow::bail!("Enum not found for variant: {:?}", variant);
};
Ok(Object::Variant(Variant {
enm: vm_enum.name.clone(),
variant: vm_enum.variant_names[variant.index].clone(),
}))
}
VmObject::Media(media) => Ok(Object::Media(media.clone())),
VmObject::Function(f) => Ok(Object::Function(f.name.clone())),
VmObject::Class(c) => Ok(Object::Class(c.name.clone())),
VmObject::Enum(e) => Ok(Object::Enum(e.name.clone())),
_ => anyhow::bail!("Unsupported object type for testing: {:?}", obj),
}
}
pub fn instance(class: &str, fields: IndexMap<&str, Value>) -> Self {
Object::Instance(Instance {
class: class.to_string(),
fields: Instance::fields(fields),
})
}
/// Shorthand for creating a function object reference.
pub fn function(name: &str) -> Self {
Object::Function(name.to_string())
}
/// Shorthand for creating a class object reference.
pub fn class(name: &str) -> Self {
Object::Class(name.to_string())View on GitHub (pinned to bd85ce9dee)