BoundaryML/baml · error
body record omitted log metadata
Error message
body record omitted log metadata
What it means
When decoding a bex_events event stream, a body record (an event body) arrived without the required log metadata (value_ref/event envelope fields). file_record_from_proto only produces a FileRecord when a preceding metadata record established the log context; otherwise it returns InvalidData. This protects the reader from assembling bodies that cannot be attributed to any log event.
Source
Thrown at baml_language/crates/bex_events/src/value/read.rs:103
return Err(io::Error::new(
io::ErrorKind::InvalidData,
"value record mixed capture loss metadata with body metadata",
));
}
return Ok(ValueFileRecord::CaptureLoss(loss.try_into()?));
}
let metadata = record.metadata.ok_or_else(|| {
io::Error::new(io::ErrorKind::InvalidData, "value record omitted metadata")
})?;
if let Some(log_event) = record.log_event {
return Ok(ValueFileRecord::LogEvent(LogRecord {
value_ref: metadata.try_into()?,
body: record.body,
blob_ref: record.blob.map(TryInto::try_into).transpose()?,
event: log_event.try_into()?,
}));
}
Err(io::Error::new(
io::ErrorKind::InvalidData,
"body record omitted log metadata",
))
}
#[cfg(test)]
mod tests {
use prost::Message as _;
use crate::{
ids::BoundaryId,
value::{
LogEventRecord, LogRecord, ValueCodec, ValueRef,
encode::{encode_header, encode_log_event},
pb,
},
};
View on GitHub (pinned to bd85ce9dee)
Solutions
- Regenerate or re-export the trace file from a healthy source; the file is missing its metadata record and cannot be repaired by the reader
- Verify the producer and consumer bex_events versions match — a newer writer may order records differently
- Check that the file was not truncated in transfer (compare sizes/checksums with the origin)
- If reading a partial stream, skip to the next complete metadata+body pair instead of the orphaned body
Example fix
// before
let record = read_bamlvalue_from_bytes(&buf)?; // panics pipeline on orphaned body
// after
match read_bamlvalue_from_bytes(&buf) {
Ok(record) => emit(record),
Err(e) if e.kind() == io::ErrorKind::InvalidData => skip_corrupt_chunk(),
Err(e) => return Err(e),
} Defensive patterns
Strategy: validation
Validate before calling
fn has_log_metadata(record: &RawRecord) -> bool { record.metadata.is_some() } Type guard
fn is_valid_body_record(r: &FileRecord) -> bool { r.event.is_some() && r.value_ref.is_some() } Try / catch
match read_bamlvalue_from_bytes(&buf) { Ok(r) => Some(r), Err(e) if e.kind() == io::ErrorKind::InvalidData => { log::warn!("skipping orphaned body record: {e}"); None }, Err(e) => return Err(e) } Prevention
- Never truncate event files mid-stream; use atomic writes or checksums
- Keep writer and reader bex_events versions aligned
- Validate record ordering (metadata before body) in your producer tests
When it happens
Trigger: Calling read_bamlvalue_from_bytes on a stream where a body record appears before its corresponding ValueMetadataV1 record, or where the metadata record was dropped/truncated/corrupted by the writer.
Common situations: Truncated or partially-written trace files (process crash mid-write), hand-edited or externally-trimmed event logs, or a writer-version that emits records in an order this reader version does not expect.
Related errors
- value metadata omitted codec
- value metadata omitted availability
- original size does not fit usize
- retained size does not fit usize
- blob size does not fit usize
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/a45b19e818b65f0f.
Report an issue: GitHub.