{"record":{"id":"09bdb435954f68c8","repo":"BoundaryML/baml","slug":"internal-error-cannot-convert-value-value-to-vm-value-class","errorCode":null,"errorMessage":"internal error: cannot convert value {value} to VM value: class '{name}' not found in VM objects","messagePattern":"internal error: cannot convert value (.+?) to VM value: class '(.+?)' not found in VM objects","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/async_vm_runtime.rs","lineNumber":1284,"sourceCode":"                    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            }\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(","sourceCodeStart":1266,"sourceCodeEnd":1302,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/async_vm_runtime.rs#L1266-L1302","documentation":"A continuation of the class lookup: the class name WAS found in resolved_class_names, but the object stored at that index in the VM is not a Class object. The runtime treats this as an internal invariant violation, since the index mapping and VM object table should be consistent.","triggerScenarios":"VM object table corrupted or mismatched with resolved class indices — this should be unreachable in normal use and indicates a bug in the BAML runtime (or custom/patched VM usage).","commonSituations":"Hitting it in practice usually means running a mismatched mix of runtime/compiler versions, or a genuine BAML bug; report it with a reproduction.","solutions":["Report the bug to the BAML repository with the full error and reproduction steps","Ensure baml-runtime, baml-compiler, and generated client versions are all from the same release","Rebuild/reinstall the BAML runtime to rule out stale artifacts"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// treat as internal bug: log full error and report upstream\nErr(e) if e.to_string().starts_with(\"internal error:\") => { log::error!(\"baml bug: {e}\"); panic!() }","preventionTips":["Use matching versions of all baml-* crates","Rebuild artifacts after upgrades","Report occurrences 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"}