{"record":{"id":"3f4c8d40c75ca68a","repo":"BoundaryML/baml","slug":"value-metadata-omitted-codec","errorCode":null,"errorMessage":"value metadata omitted codec","messagePattern":"value metadata omitted codec","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_events/src/value/record.rs","lineNumber":155,"sourceCode":"    pub timestamp_ms: u64,\n}\n\n#[derive(Clone, Debug, PartialEq, Eq)]\npub enum ValueFileRecord {\n    LogEvent(LogRecord),\n    CaptureLoss(CaptureLossRecord),\n    RunStarted(RunStartedRecord),\n    RunCompleted(RunCompletedRecord),\n}\n\nimpl TryFrom<crate::value::pb::ValueMetadataV1> for ValueRef {\n    type Error = io::Error;\n\n    fn try_from(metadata: crate::value::pb::ValueMetadataV1) -> Result<Self, Self::Error> {\n        let codec = match metadata.codec() {\n            crate::value::pb::ValueCodec::BamlOutboundValue => ValueCodec::BamlOutboundValue,\n            crate::value::pb::ValueCodec::Unspecified => {\n                return Err(io::Error::new(\n                    io::ErrorKind::InvalidData,\n                    \"value metadata omitted codec\",\n                ));\n            }\n        };\n        let availability = match metadata.availability() {\n            crate::value::pb::ValueAvailability::Pending => ValueAvailability::Pending,\n            crate::value::pb::ValueAvailability::Available => ValueAvailability::Available,\n            crate::value::pb::ValueAvailability::Missing => ValueAvailability::Missing,\n            crate::value::pb::ValueAvailability::Omitted => ValueAvailability::Omitted,\n            crate::value::pb::ValueAvailability::Lost => ValueAvailability::Lost,\n            crate::value::pb::ValueAvailability::Unspecified => {\n                return Err(io::Error::new(\n                    io::ErrorKind::InvalidData,\n                    \"value metadata omitted availability\",\n                ));\n            }\n        };","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_events/src/value/record.rs#L137-L173","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nlet mut md = pb::ValueMetadataV1::default();\nmd.availability = ...\n// after\nlet mut md = pb::ValueMetadataV1::default();\nmd.codec = pb::ValueCodec::BamlOutboundValue.into();\nmd.availability = ...","handlingStrategy":"validation","validationCode":"if md.codec() == pb::ValueCodec::Unspecified { return Err(\"codec unset\"); }","typeGuard":"fn has_codec(md: &pb::ValueMetadataV1) -> bool { md.codec() != pb::ValueCodec::Unspecified }","tryCatchPattern":"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) }","preventionTips":["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"],"tags":["rust","protobuf","deserialization","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}