BoundaryML/baml · error

value record omitted metadata

Error message

value record omitted metadata

What it means

After lifecycle and capture_loss checks, every remaining value-file record must include metadata; file_record_from_proto fails with this error when record.metadata is None. Metadata carries the value_ref and trace context, so a body or log event without it cannot be attributed. Raised as io::Error(InvalidData) during read_bamlvalue_from_bytes.

Source

Thrown at baml_language/crates/bex_events/src/value/read.rs:93

        ));
    }
    if let Some(started) = record.run_started {
        return Ok(ValueFileRecord::RunStarted(started.try_into()?));
    }
    if let Some(completed) = record.run_completed {
        return Ok(ValueFileRecord::RunCompleted(completed.try_into()?));
    }
    if let Some(loss) = record.capture_loss {
        if record.metadata.is_some() || has_log_event {
            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 _;

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Regenerate the value file; a record missing metadata is unattributable and should be treated as corrupt.
  2. Fix the writer so every LogEvent/body record includes the metadata (value_ref) field.
  3. Check for interrupted writes — enable atomic/whole-record writes or detect truncation before reading.

Example fix

// before
let record = ValueFileRecordProto { body, ..Default::default() }; // metadata omitted
// after
let record = ValueFileRecordProto { metadata: Some(meta_proto), body, ..Default::default() };
Defensive patterns

Strategy: validation

Validate before calling

if record.metadata.is_none() && record.run_started.is_none()
    && record.run_completed.is_none() && record.capture_loss.is_none() {
    // record is missing metadata; do not write it
}

Try / catch

let value = read_bamlvalue_from_bytes(&bytes).map_err(|e| {
    if e.to_string().contains("omitted metadata") {
        eprintln!("record missing value_ref metadata — file likely truncated: {e}");
    }
    e
})?;

Prevention

When it happens

Trigger: Decoding a record that has no lifecycle oneof, no capture_loss, and no metadata — e.g. a truncated write that zeroed the metadata field, or a writer that emitted a body without metadata.

Common situations: Truncated/corrupted files from a crash mid-write, hand-crafted records in tests or tools, or buggy custom writers omitting the metadata field for log events.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/4e21810f1400d682. Report an issue: GitHub.