{"record":{"id":"4bfc3bd5689af35f","repo":"BoundaryML/baml","slug":"unsupported-raw-pointer-type","errorCode":null,"errorMessage":"unsupported raw pointer type","messagePattern":"unsupported raw pointer type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_cffi/src/ctypes/baml_value_decode.rs","lineNumber":35,"sourceCode":"        crate::ffi::Value::String(s, _) => Ok(BamlValue::String(s)),\n        crate::ffi::Value::Int(i, _) => Ok(BamlValue::Int(i)),\n        crate::ffi::Value::Float(f, _) => Ok(BamlValue::Float(f)),\n        crate::ffi::Value::Bool(b, _) => Ok(BamlValue::Bool(b)),\n        crate::ffi::Value::Map(m, _) => Ok(BamlValue::Map(\n            m.into_iter()\n                .map(|(k, v)| from_ffi_value_to_baml_value(v).map(|v| (k, v)))\n                .collect::<Result<_, _>>()?,\n        )),\n        crate::ffi::Value::List(l, _) => Ok(BamlValue::List(\n            l.into_iter()\n                .map(from_ffi_value_to_baml_value)\n                .collect::<Result<_, _>>()?,\n        )),\n        crate::ffi::Value::RawPtr(r, _) => match r {\n            crate::raw_ptr_wrapper::RawPtrType::Media(raw_ptr_wrapper) => {\n                Ok(BamlValue::Media(raw_ptr_wrapper.as_ref().clone()))\n            }\n            _ => anyhow::bail!(\"unsupported raw pointer type\"),\n        },\n        crate::ffi::Value::Class(c, fields, _) => Ok(BamlValue::Class(\n            c,\n            fields\n                .into_iter()\n                .map(|(k, v)| from_ffi_value_to_baml_value(v).map(|v| (k, v)))\n                .collect::<Result<_, _>>()?,\n        )),\n        crate::ffi::Value::Enum(e, value, _) => Ok(BamlValue::Enum(e, value)),\n    }\n}\n\npub(super) fn from_host_kv_to_baml_kv(\n    item: crate::baml::cffi::HostMapEntry,\n) -> Result<(String, BamlValue), anyhow::Error> {\n    use crate::baml::cffi::host_map_entry::Key;\n    let key = match item.key {\n        Some(Key::StringKey(key)) => key,","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_cffi/src/ctypes/baml_value_decode.rs#L17-L53","documentation":"When decoding FFI values back into BamlValue, RawPtr values are only understood when they wrap Media data. Any other RawPtrType cannot be converted and the decoder bails with this error — a pointer of an unexpected kind crossed the FFI boundary.","triggerScenarios":"Calling a BAML function through the CFFI decode path where the host passed or the runtime returned a Value::RawPtr whose RawPtrType is not Media (e.g. another pointer variant), typically from an internal API misuse or version-mismatched host library.","commonSituations":"Mixing versions of the CFFI host binding and the BAML runtime; passing an unsupported opaque object (non-media) through FFI arguments; internal bug in pointer type tagging.","solutions":["Ensure the host bindings and the BAML runtime are the same version (reinstall matching packages)","Pass media (images/audio) as supported Media objects, not other pointer types","Pass plain values (strings, ints, maps) instead of raw pointers where possible","If reproducible with matching versions, file a bug with a minimal repro"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isMediaArg(v) {\n  return v instanceof Image || v instanceof Audio || typeof v === 'string' || typeof v === 'number';\n}\n// only pass media/raw-pointer-supported values across the FFI boundary","tryCatchPattern":"try {\n  const out = await bamlClient.MyFunction(args);\n} catch (e) {\n  if (String(e).includes('unsupported raw pointer type')) {\n    console.error('Unsupported object passed over FFI; pass media or plain values');\n  }\n}","preventionTips":["Match host binding and runtime versions exactly","Pass only documented FFI value types (primitives, media, maps, classes)","Reproduce with minimal args before filing a bug"],"tags":["cffi","ffi","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}