{"record":{"id":"04c11bea193abb1b","repo":"BoundaryML/baml","slug":"cannot-convert-value-value-to-vm-value-class-name-not-found","errorCode":null,"errorMessage":"cannot convert value {value} to VM value: class '{name}' not found","messagePattern":"cannot convert value (.+?) to VM value: class '(.+?)' not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/async_vm_runtime.rs","lineNumber":1280,"sourceCode":"\n            for (k, v) in map {\n                vm_map.insert(\n                    k.to_owned(),\n                    try_vm_value_from_baml_value(\n                        vm,\n                        resolved_class_names,\n                        resolved_enums_names,\n                        v,\n                    )?,\n                );\n            }\n\n            Ok(vm.alloc_map(vm_map))\n        }\n\n        BamlValue::Class(name, fields) => {\n            let Some(class_index) = resolved_class_names.get(name) else {\n                anyhow::bail!(\"cannot convert value {value} to VM value: class '{name}' not found\");\n            };\n\n            let baml_vm::Object::Class(class) = &vm.objects[*class_index] else {\n                anyhow::bail!(\n                    \"internal error: cannot convert value {value} to VM value: class '{name}' not found in VM objects\"\n                );\n            };\n\n            let mut ordered_field_values = Vec::new();\n            for field_name in &class.field_names {\n                let Some(value) = fields.get(field_name) else {\n                    anyhow::bail!(\n                        \"cannot convert value {value} to VM value: class '{name}' has no field '{field_name}'\"\n                    );\n                };\n\n                ordered_field_values.push(value);\n            }","sourceCodeStart":1262,"sourceCodeEnd":1298,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/async_vm_runtime.rs#L1262-L1298","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before calling, ensure class name exists in schema\nassert classes_in_baml_project().contains(\"MyClass\")","typeGuard":"fn class_name_known(name: &str, resolved: &HashMap<String, usize>) -> bool { resolved.contains_key(name) }","tryCatchPattern":"match try_vm_value_from_baml_value(...) { Err(e) if e.to_string().contains(\"class '\") => { /* regenerate client / fix schema */ }, ... }","preventionTips":["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"],"tags":["baml","class","internal"],"backgroundTag":"class-not-found","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"}