BoundaryML/baml · error · RuntimeError
{e:?}
Error message
{e:?} What it means
Ruby FFI generic serialization error: converting the HTTP request's headers into a Ruby hash via serde_magnus failed. The {e:?} is the magnus conversion error (e.g. a header value type that has no Ruby representation). This is the catch-all serialization guard for the headers accessor on the Ruby HTTPRequest wrapper.
Source
Thrown at engine/language_client_ruby/ext/ruby_ffi/src/types/request.rs:45
)
}
pub fn id(&self) -> String {
self.inner.id().to_string()
}
pub fn url(&self) -> String {
self.inner.url().to_string()
}
pub fn method(&self) -> String {
self.inner.method().to_string()
}
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("HTTPRequest", class::object())?;
cls.define_method("to_s", method!(HTTPRequest::to_s, 0))?;
cls.define_method("id", method!(HTTPRequest::id, 0))?;
cls.define_method("url", method!(HTTPRequest::url, 0))?;
cls.define_method("method", method!(HTTPRequest::method, 0))?;
cls.define_method("headers", method!(HTTPRequest::headers, 0))?;
cls.define_method("body", method!(HTTPRequest::body, 0))?;
Ok(())View on GitHub (pinned to bd85ce9dee)
Solutions
- Rebuild/reinstall the baml gem so native extension and runtime versions match.
- Log the debug serde error from the message to find the offending header.
- Update to the latest baml release where serialization bugs may be fixed.
Example fix
// before
h = request.headers # RuntimeError: {e:?}
// after
begin
h = request.headers
rescue RuntimeError => e
h = {}
logger.warn("headers serialization failed: #{e.message}")
end Defensive patterns
Strategy: try-catch
Try / catch
begin
headers = request.headers
rescue RuntimeError => e
headers = {}
end Prevention
- Align Ruby client gem and Rust runtime versions.
- Surface the debug serde message when reporting issues.
When it happens
Trigger: Calling headers on an FFI HTTPRequest object when the internal header map cannot be serialized into a Ruby value.
Common situations: Version mismatch between the Ruby gem and the compiled native extension, or unusual header values (non-UTF8 / non-string-mappable) produced upstream.
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/b8a382cca0d82d1f.
Report an issue: GitHub.