{"record":{"id":"ae47a35f4b2719f0","repo":"BoundaryML/baml","slug":"internal-error-cannot-convert-value-value-to-vm-value-enum","errorCode":null,"errorMessage":"internal error: cannot convert value {value} to VM value: enum '{enm}' not found in VM objects","messagePattern":"internal error: cannot convert value (.+?) to VM value: enum '(.+?)' not found in VM objects","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/async_vm_runtime.rs","lineNumber":1319,"sourceCode":"            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())),\n    }\n}\n\nfn try_vm_value_from_function_result(","sourceCodeStart":1301,"sourceCodeEnd":1337,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/async_vm_runtime.rs#L1301-L1337","documentation":"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.","triggerScenarios":"VM object table inconsistent with resolved enum indices — indicates a BAML runtime bug or mismatched runtime/compiler artifacts.","commonSituations":"Mixing versions of baml-runtime and baml-compiler; patched or custom VM builds; otherwise a bug to report upstream.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"Err(e) if e.to_string().starts_with(\"internal error:\") => { log::error!(\"baml bug: {e}\"); panic!() }","preventionTips":["Align baml-* crate versions","Clean rebuild after upgrades","Report upstream with reproduction"],"tags":["baml","internal","bug"],"backgroundTag":"internal-invariant-violation","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"}