{"record":{"id":"8901e369b5ca7e79","repo":"BoundaryML/baml","slug":"capture-loss-omitted-kind","errorCode":null,"errorMessage":"capture loss omitted kind","messagePattern":"capture loss omitted kind","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_events/src/value/record.rs","lineNumber":358,"sourceCode":"    fn from(value: &LogEventRecord) -> Self {\n        Self {\n            call: Some(value.call.into()),\n            level: value.level.clone(),\n            source: value.source.as_ref().map(Into::into),\n            timestamp_ms: value.timestamp_ms,\n            message_preview: value.message_preview.clone(),\n        }\n    }\n}\n\nimpl TryFrom<crate::value::pb::CaptureLossV1> for CaptureLossRecord {\n    type Error = io::Error;\n\n    fn try_from(value: crate::value::pb::CaptureLossV1) -> Result<Self, Self::Error> {\n        let kind = match value.kind() {\n            crate::value::pb::CaptureLossKind::Log => CaptureLossKind::Log,\n            crate::value::pb::CaptureLossKind::Unspecified => {\n                return Err(io::Error::new(\n                    io::ErrorKind::InvalidData,\n                    \"capture loss omitted kind\",\n                ));\n            }\n        };\n        let reason = match value.reason() {\n            crate::value::pb::CaptureLossReason::QueueFull => CaptureLossReason::QueueFull,\n            crate::value::pb::CaptureLossReason::Unspecified => {\n                return Err(io::Error::new(\n                    io::ErrorKind::InvalidData,\n                    \"capture loss omitted reason\",\n                ));\n            }\n        };\n        Ok(Self {\n            kind,\n            reason,\n            skipped_count: value.skipped_count,","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_events/src/value/record.rs#L340-L376","documentation":"CaptureLossV1 records that telemetry was dropped (e.g. a queue overflow); its 'kind' enum must be explicitly set (currently Log). When kind() returns Unspecified — the proto3 default for an unset enum — the TryFrom conversion rejects the record with InvalidData and this message, since a loss record without a kind is meaningless.","triggerScenarios":"Decoding a CaptureLossV1 whose kind field was never set by the writer, or was reset when the message was copied/rebuilt by intermediate code.","commonSituations":"Older writers predating the kind field, hand-built loss records in tests/tools, migration code that reconstructs the proto without copying enum fields.","solutions":["Fix the producer to set kind = CaptureLossKind::Log (or the appropriate kind) on every loss record","Set the enum explicitly when constructing the proto manually (avoid ..Default::default() for enum fields)","Default Unspecified to Log at decode time if your data contract guarantees only log-loss records exist","Check writer/reader version skew and migrate legacy streams"],"exampleFix":"// before\nlet loss = pb::CaptureLossV1 { reason: ..., ..Default::default() };\n// after\nlet loss = pb::CaptureLossV1 { kind: pb::CaptureLossKind::Log as i32, reason: ..., ..Default::default() };","handlingStrategy":"validation","validationCode":"fn loss_kind_set(loss: &pb::CaptureLossV1) -> bool { loss.kind() != pb::CaptureLossKind::Unspecified }","typeGuard":"fn valid_loss_kind(loss: &pb::CaptureLossV1) -> bool { matches!(loss.kind(), pb::CaptureLossKind::Log) }","tryCatchPattern":"CaptureLossRecord::try_from(loss).map_err(|e| if e.to_string().contains(\"omitted kind\") { default_kind_record(loss) } else { e })","preventionTips":["Always set enum fields on loss records; never rely on proto3 defaults","Round-trip test CaptureLossV1 serialization","Migrate writers that predate the kind field"],"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"}