{"record":{"id":"5a656bec8731df9e","repo":"BoundaryML/baml","slug":"error-parsing-function-result-e","errorCode":null,"errorMessage":"error parsing function result: {e}","messagePattern":"error parsing function result: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/async_vm_runtime.rs","lineNumber":1351,"sourceCode":"        BamlValue::Media(media) => Ok(vm.alloc_media(media.clone())),\n    }\n}\n\nfn try_vm_value_from_function_result(\n    vm: &mut Vm,\n    resolved_class_names: &HashMap<String, ObjectIndex>,\n    resolved_enums_names: &HashMap<String, ObjectIndex>,\n    result: anyhow::Result<FunctionResult>,\n) -> anyhow::Result<baml_vm::Value> {\n    let fn_result = result.context(\"failed to get function result\")?;\n\n    // TODO: Return type of .parsed() sucks.\n    let baml_value = fn_result\n        .parsed()\n        .as_ref()\n        .ok_or_else(|| anyhow!(\"no parsed result available from function call\"))?\n        .as_ref()\n        .map_err(|e| anyhow!(\"error parsing function result: {e}\"))?\n        .clone()\n        .0\n        .value();\n\n    try_vm_value_from_baml_value(vm, resolved_class_names, resolved_enums_names, &baml_value)\n}\n\nimpl crate::runtime_interface::InternalRuntimeInterface for BamlAsyncVmRuntime {\n    fn features(&self) -> crate::internal::ir_features::IrFeatures {\n        self.llm_runtime.features()\n    }\n\n    fn diagnostics(&self) -> &internal_baml_core::internal_baml_diagnostics::Diagnostics {\n        self.llm_runtime.diagnostics()\n    }\n\n    fn orchestration_graph(\n        &self,","sourceCodeStart":1333,"sourceCodeEnd":1369,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/async_vm_runtime.rs#L1333-L1369","documentation":"The function result did have a parsed slot, but the inner parse operation failed with error e. The runtime wraps that error as 'error parsing function result: {e}', meaning the LLM output could not be coerced into the declared output type.","triggerScenarios":"baml function call where the model's raw response fails jsonish parsing against the output format — invalid JSON, wrong shape, truncated output, or missing required fields.","commonSituations":"Models returning markdown-fenced or truncated JSON; output type expecting fields the model omitted; very long responses cut off by max token limits.","solutions":["Inspect the wrapped inner error e to see which field/shape failed","Tighten the prompt/schema, or make fields optional/nullable where the model may omit them","Enable BAML's retry policy or output 'repair' behaviors for malformed JSON","Increase max output tokens if truncation is the cause"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"if let Some(parsed) = fn_result.parsed() { if parsed.is_err() { handle_parse_failure(parsed.unwrap_err()); } }","tryCatchPattern":"Err(e) if e.to_string().starts_with(\"error parsing function result:\") => { /* read inner cause, adjust schema/prompt, retry */ }","preventionTips":["Enable BAML retry policies for parse failures","Make optional model-omitted fields nullable","Increase max output tokens to avoid truncation","Prefer strict JSON output instructions in prompts"],"tags":["baml","parsing","llm"],"backgroundTag":"invalid-json-response","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"}