{"record":{"id":"51c2a276e787c132","repo":"BoundaryML/baml","slug":"run-started-record-omitted-target","errorCode":null,"errorMessage":"run started record omitted target","messagePattern":"run started record omitted target","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_events/src/value/record.rs","lineNumber":406,"sourceCode":"            reason: match value.reason {\n                CaptureLossReason::QueueFull => {\n                    crate::value::pb::CaptureLossReason::QueueFull as i32\n                }\n            },\n            skipped_count: value.skipped_count,\n            call: value.call.map(Into::into),\n            message: value.message.clone(),\n            timestamp_ms: value.timestamp_ms,\n        }\n    }\n}\n\nimpl TryFrom<crate::value::pb::RunStartedV1> for RunStartedRecord {\n    type Error = io::Error;\n\n    fn try_from(value: crate::value::pb::RunStartedV1) -> Result<Self, Self::Error> {\n        let target = value.target.ok_or_else(|| {\n            io::Error::new(\n                io::ErrorKind::InvalidData,\n                \"run started record omitted target\",\n            )\n        })?;\n        let time_anchor = value.time_anchor.ok_or_else(|| {\n            io::Error::new(\n                io::ErrorKind::InvalidData,\n                \"run started record omitted time anchor\",\n            )\n        })?;\n        Ok(Self {\n            request: RunRequestSummary {\n                project_id: ProjectId(value.project_id),\n                project_generation: ProjectGeneration(value.project_generation),\n                target: run_target_from_proto(target)?,\n                args_summary: value.args_summary,\n                options_summary: value.options_summary,\n            },","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_events/src/value/record.rs#L388-L424","documentation":"This io::Error (InvalidData) is thrown by TryFrom<pb::RunStartedV1> for RunStartedRecord when the decoded protobuf message has no `target` field set. In proto3, optional message fields decode to None when absent, and the record type requires a target (which function/test is being run), so conversion fails fast rather than constructing a record with an unusable target.","triggerScenarios":"Calling RunStartedRecord::try_from(pb_run_started) where the RunStartedV1 message was built without set_target(), or a serialized event was truncated/mutated so the target oneof is missing on decode.","commonSituations":"A producer of bex_events upgraded its protobuf schema and stopped populating target; hand-crafted test fixtures that only fill in time_anchor; a partial write/corruption of the event stream dropping the field.","solutions":["Ensure the producer sets target (set_target(pb::RunTargetV1{...})) on every RunStartedV1 before serializing","Check which emitter wrote the event and fix it to populate the required field","Regenerate or repair the corrupted event-stream segment so the field is present","Handle the Err case at decode time and skip/report the malformed record instead of panicking"],"exampleFix":"// before\nlet rec = RunStartedRecord::try_from(msg)?; // msg.target unset -> InvalidData\n// after\nmsg.target = Some(pb::RunTargetV1 { target: Some(run_target_v1::Target::Function(...)) });\nlet rec = RunStartedRecord::try_from(msg)?;","handlingStrategy":"validation","validationCode":"fn is_valid(msg: &pb::RunStartedV1) -> bool { msg.target.is_some() }\n// only call try_from when true","typeGuard":"fn has_target(msg: &pb::RunStartedV1) -> Option<&pb::RunTargetV1> { msg.target.as_ref() }","tryCatchPattern":"match RunStartedRecord::try_from(msg) {\n    Ok(rec) => rec,\n    Err(e) if e.kind() == io::ErrorKind::InvalidData => { log::warn!(\"malformed run-started: {e}\"); return; },\n    Err(e) => return Err(e),\n}","preventionTips":["Always set target on RunStartedV1 before serializing","Add producer-side assertions for required optional proto fields","Round-trip test fixtures (serialize/parse/convert) in CI"],"tags":["protobuf","deserialization","missing-field"],"backgroundTag":"missing-required-argument","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}