{"record":{"id":"49bf88f27ec2a955","repo":"BoundaryML/baml","slug":"e-response","errorCode":null,"errorMessage":"{e:?}","messagePattern":"\\{e:\\?\\}","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"engine/language_client_ruby/ext/ruby_ffi/src/types/response.rs","lineNumber":30,"sourceCode":"\nimpl HTTPResponse {\n    pub fn to_s(&self) -> String {\n        format!(\n            \"HTTPResponse(status={}, headers={}, body={})\",\n            self.inner.status,\n            serde_json::to_string_pretty(&self.inner.headers()).unwrap_or_default(),\n            serde_json::to_string_pretty(&self.inner.body.as_serde_value()).unwrap_or_default()\n        )\n    }\n\n    pub fn status(&self) -> u16 {\n        self.inner.status\n    }\n\n    pub fn headers(ruby: &Ruby, rb_self: &Self) -> Result<magnus::Value> {\n        // Convert headers to Ruby hash\n        serde_magnus::serialize(&rb_self.inner.headers())\n            .map_err(|e| Error::new(ruby.exception_runtime_error(), format!(\"{e:?}\")))\n    }\n\n    pub fn body(&self) -> HTTPBody {\n        // TODO: Avoid clone.\n        HTTPBody::from(self.inner.body.clone())\n    }\n\n    pub fn define_in_ruby(module: &RModule) -> Result<()> {\n        let cls = module.define_class(\"HTTPResponse\", class::object())?;\n\n        cls.define_method(\"to_s\", method!(HTTPResponse::to_s, 0))?;\n        cls.define_method(\"status\", method!(HTTPResponse::status, 0))?;\n        cls.define_method(\"headers\", method!(HTTPResponse::headers, 0))?;\n        cls.define_method(\"body\", method!(HTTPResponse::body, 0))?;\n\n        Ok(())\n    }\n}","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_ruby/ext/ruby_ffi/src/types/response.rs#L12-L48","documentation":"Ruby FFI generic serialization error: converting the HTTP response's headers into a Ruby hash via serde_magnus failed, with the conversion error carried verbatim in {e:?. It mirrors the request-side headers accessor and fires when the header map contains something serde_magnus cannot map into a Ruby value — effectively a wrapper/runtime version mismatch.","triggerScenarios":"Calling headers on an FFI HTTPResponse when the internal header map cannot be serialized to Ruby.","commonSituations":"Gem/native-extension version mismatch, or header values the serde-to-Ruby bridge cannot represent; often after partial upgrades of the baml gem.","solutions":["Reinstall/rebuild the baml gem so the extension matches the runtime.","Update to the latest baml version.","Capture the debug serde error from the message to identify the failing header."],"exampleFix":"// before\nh = response.headers # RuntimeError: {e:?}\n// after\nbegin\n  h = response.headers\nrescue RuntimeError => e\n  h = {}\n  logger.warn(\"response headers serialization failed: #{e.message}\")\nend","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"begin\n  headers = response.headers\nrescue RuntimeError => e\n  headers = {}\nend","preventionTips":["Keep gem and native extension versions matched.","Update baml to the latest release."],"tags":["ruby","ffi","serialization","http-headers"],"backgroundTag":"json-marshal-failed","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"}