{"record":{"id":"0d31b024bb9026f3","repo":"BoundaryML/baml","slug":"cannot-convert-value-value-to-vm-value-class-name-has-no","errorCode":null,"errorMessage":"cannot convert value {value} to VM value: class '{name}' has no field '{field_name}'","messagePattern":"cannot convert value (.+?) to VM value: class '(.+?)' has no field '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/async_vm_runtime.rs","lineNumber":1292,"sourceCode":"\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            }\n\n            let mut vm_fields_layout = Vec::new();\n            for v in ordered_field_values {\n                vm_fields_layout.push(try_vm_value_from_baml_value(\n                    vm,\n                    resolved_class_names,\n                    resolved_enums_names,\n                    v,\n                )?);\n            }\n\n            Ok(vm.alloc_instance(*class_index, vm_fields_layout))","sourceCodeStart":1274,"sourceCodeEnd":1310,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/async_vm_runtime.rs#L1274-L1310","documentation":"When materializing a BamlValue::Class into a VM value, the runtime iterates the VM class's declared field names and requires each one to be present in the value's field map. This error means the value is missing a field that the class declares.","triggerScenarios":"Constructing a BamlValue::Class (e.g. from code that builds function arguments or results) with a field map that lacks one of the class's declared fields, then calling a function with it.","commonSituations":"Manually building class values in Rust/Python/TS integrations and forgetting a newly added field after editing the .baml class; optional/nullable handling changes; partial deserialization dropping fields.","solutions":["Populate every declared field of the class in the value's field map (use null for optional fields)","Regenerate the client after changing the .baml class so field lists match","Compare the field map keys against the class definition in the .baml file"],"exampleFix":"// before (Rust)\nBamlValue::Class(\"User\".into(), vec![(\"name\".into(), BamlValue::String(\"a\".into()))].into_iter().collect())\n// after (Rust)\nBamlValue::Class(\"User\".into(), vec![(\"name\".into(), BamlValue::String(\"a\".into())), (\"age\".into(), BamlValue::Int(0))].into_iter().collect())","handlingStrategy":"validation","validationCode":"// check all declared fields present before constructing value\nfor f in class.field_names { assert!(fields.contains_key(f), \"missing field {f}\") }","typeGuard":"fn has_all_fields(fields: &HashMap<String, BamlValue>, required: &[&str]) -> bool { required.iter().all(|f| fields.contains_key(*f)) }","tryCatchPattern":"Err(e) if e.to_string().contains(\"has no field\") => { /* add missing field or regenerate client */ }","preventionTips":["Regenerate the client after adding fields to a class","Initialize all fields when building class values programmatically","Use nullable defaults for optional fields"],"tags":["baml","class","fields"],"backgroundTag":"schema-validation-failed","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}