BoundaryML/baml · error
value metadata omitted codec
Error message
value metadata omitted codec
What it means
ValueMetadataV1.protobuf carried codec == Unspecified, meaning the writer never set which codec encoded the value (required: BamlOutboundValue). The TryFrom<crate::value::pb::ValueMetadataV1> conversion for the internal record rejects any metadata lacking an explicit codec because the decoder cannot know how to interpret the payload. It is a strict validation error (io::ErrorKind::InvalidData).
Source
Thrown at baml_language/crates/bex_events/src/value/record.rs:155
pub timestamp_ms: u64,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ValueFileRecord {
LogEvent(LogRecord),
CaptureLoss(CaptureLossRecord),
RunStarted(RunStartedRecord),
RunCompleted(RunCompletedRecord),
}
impl TryFrom<crate::value::pb::ValueMetadataV1> for ValueRef {
type Error = io::Error;
fn try_from(metadata: crate::value::pb::ValueMetadataV1) -> Result<Self, Self::Error> {
let codec = match metadata.codec() {
crate::value::pb::ValueCodec::BamlOutboundValue => ValueCodec::BamlOutboundValue,
crate::value::pb::ValueCodec::Unspecified => {
return Err(io::Error::new(
io::ErrorKind::InvalidData,
"value metadata omitted codec",
));
}
};
let availability = match metadata.availability() {
crate::value::pb::ValueAvailability::Pending => ValueAvailability::Pending,
crate::value::pb::ValueAvailability::Available => ValueAvailability::Available,
crate::value::pb::ValueAvailability::Missing => ValueAvailability::Missing,
crate::value::pb::ValueAvailability::Omitted => ValueAvailability::Omitted,
crate::value::pb::ValueAvailability::Lost => ValueAvailability::Lost,
crate::value::pb::ValueAvailability::Unspecified => {
return Err(io::Error::new(
io::ErrorKind::InvalidData,
"value metadata omitted availability",
));
}
};View on GitHub (pinned to bd85ce9dee)
Solutions
- Upgrade or align the producer so it always sets codec = BamlOutboundValue before writing
- If constructing the proto manually, call the codec setter (value.codec = ValueCodec::BamlOutboundValue as i32)
- Reject/repair affected records at ingest time with a default codec if you know all data is BamlOutboundValue
- Check writer version in the stream header and route old streams through a migration path
Example fix
// before let mut md = pb::ValueMetadataV1::default(); md.availability = ... // after let mut md = pb::ValueMetadataV1::default(); md.codec = pb::ValueCodec::BamlOutboundValue.into(); md.availability = ...
Defensive patterns
Strategy: validation
Validate before calling
if md.codec() == pb::ValueCodec::Unspecified { return Err("codec unset"); } Type guard
fn has_codec(md: &pb::ValueMetadataV1) -> bool { md.codec() != pb::ValueCodec::Unspecified } Try / catch
match ValueRecord::try_from(md) { Ok(r) => Some(r), Err(e) if e.to_string().contains("omitted codec") => default_codec_record(md), Err(e) => return Err(e) } Prevention
- Always set enum fields explicitly; avoid proto3 enum defaults in writers
- Add a round-trip test asserting codec survives serialization
- Pin producer/consumer schema versions
When it happens
Trigger: Decoding a ValueMetadataV1 message whose codec field was left at the proto3 default (Unspecified) — e.g. produced by old writer code before the codec field existed, or a message constructed by hand in tests without setting codec.
Common situations: Mixing writer/reader versions across a schema migration, manually constructing pb::ValueMetadataV1 in tests or tools and forgetting .set_codec(), or a proxy/transform layer that rebuilds the proto and drops the field.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- value metadata omitted availability
- capture loss omitted kind
- capture loss omitted reason
- body record omitted log metadata
- original size does not fit usize
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/3f4c8d40c75ca68a.
Report an issue: GitHub.