{"record":{"id":"b982435952b86fa1","repo":"BoundaryML/baml","slug":"cannot-convert-value-value-to-vm-value-enum-enm-not-found","errorCode":null,"errorMessage":"cannot convert value {value} to VM value: enum '{enm}' not found","messagePattern":"cannot convert value (.+?) to VM value: enum '(.+?)' not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/async_vm_runtime.rs","lineNumber":1315,"sourceCode":"                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))\n        }\n\n        BamlValue::Enum(enm, variant) => {\n            let Some(enum_index) = resolved_enums_names.get(enm) else {\n                anyhow::bail!(\"cannot convert value {value} to VM value: enum '{enm}' not found\");\n            };\n\n            let baml_vm::Object::Enum(enm) = &vm.objects[*enum_index] else {\n                anyhow::bail!(\n                    \"internal error: cannot convert value {value} to VM value: enum '{enm}' not found in VM objects\"\n                );\n            };\n\n            let Some(variant_index) = enm.variant_names.iter().position(|v| v == variant) else {\n                anyhow::bail!(\n                    \"cannot convert value {value} to VM value: enum '{enm}' has no variant '{variant}'\"\n                );\n            };\n\n            Ok(vm.alloc_variant(*enum_index, variant_index))\n        }\n\n        BamlValue::Media(media) => Ok(vm.alloc_media(media.clone())),","sourceCodeStart":1297,"sourceCodeEnd":1333,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/async_vm_runtime.rs#L1297-L1333","documentation":"When converting a BamlValue::Enum back into a VM value, the runtime looks up the enum name among the function's resolved enums. This error means the enum name on the value has no matching enum definition in the resolved set.","triggerScenarios":"A function result or argument value carries an enum name not declared (or renamed/deleted) in the .baml files resolved for that function.","commonSituations":"Renaming an enum in .baml without regenerating clients; cross-project value sharing; typos in enum names when constructing values programmatically.","solutions":["Regenerate the BAML client so enum names match the current .baml schema","Verify the enum name in the value exactly matches a declared enum (case-sensitive)","Ensure the enum is part of the same project/function's resolved definitions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"assert enums_in_baml_project().contains(\"MyEnum\")","typeGuard":"fn enum_name_known(name: &str, resolved: &HashMap<String, usize>) -> bool { resolved.contains_key(name) }","tryCatchPattern":"Err(e) if e.to_string().contains(\"enum '\") => { /* fix enum name / regenerate */ }","preventionTips":["Regenerate clients after enum edits","Match enum names exactly (case-sensitive)","Keep values within one project's resolved definitions"],"tags":["baml","enum","internal"],"backgroundTag":"invalid-enum-value","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"}