BoundaryML/baml · error · RuntimeError
{e:?}
Error message
{e:?} What it means
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.
Source
Thrown at engine/language_client_ruby/ext/ruby_ffi/src/types/response.rs:30
impl HTTPResponse {
pub fn to_s(&self) -> String {
format!(
"HTTPResponse(status={}, headers={}, body={})",
self.inner.status,
serde_json::to_string_pretty(&self.inner.headers()).unwrap_or_default(),
serde_json::to_string_pretty(&self.inner.body.as_serde_value()).unwrap_or_default()
)
}
pub fn status(&self) -> u16 {
self.inner.status
}
pub fn headers(ruby: &Ruby, rb_self: &Self) -> Result<magnus::Value> {
// Convert headers to Ruby hash
serde_magnus::serialize(&rb_self.inner.headers())
.map_err(|e| Error::new(ruby.exception_runtime_error(), format!("{e:?}")))
}
pub fn body(&self) -> HTTPBody {
// TODO: Avoid clone.
HTTPBody::from(self.inner.body.clone())
}
pub fn define_in_ruby(module: &RModule) -> Result<()> {
let cls = module.define_class("HTTPResponse", class::object())?;
cls.define_method("to_s", method!(HTTPResponse::to_s, 0))?;
cls.define_method("status", method!(HTTPResponse::status, 0))?;
cls.define_method("headers", method!(HTTPResponse::headers, 0))?;
cls.define_method("body", method!(HTTPResponse::body, 0))?;
Ok(())
}
}View on GitHub (pinned to bd85ce9dee)
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.
Example fix
// before
h = response.headers # RuntimeError: {e:?}
// after
begin
h = response.headers
rescue RuntimeError => e
h = {}
logger.warn("response headers serialization failed: #{e.message}")
end Defensive patterns
Strategy: try-catch
Try / catch
begin
headers = response.headers
rescue RuntimeError => e
headers = {}
end Prevention
- Keep gem and native extension versions matched.
- Update baml to the latest release.
When it happens
Trigger: Calling headers on an FFI HTTPResponse when the internal header map cannot be serialized to Ruby.
Common situations: Gem/native-extension version mismatch, or header values the serde-to-Ruby bridge cannot represent; often after partial upgrades of the baml gem.
Understand the failure class
Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.
Related errors
- {e:?}
- failed coercing BAML value to Ruby value: {e:?}
- failed to convert Ruby object to JSON, errors were: {} Ruby
- encoding method arguments: %w
- unsupported map key type: %s
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/49bf88f27ec2a955.
Report an issue: GitHub.