{"record":{"id":"f6260a2391442d87","repo":"BoundaryML/baml","slug":"history-boundary-has-inconsistent-value-segment-boundary-ids","errorCode":null,"errorMessage":"history boundary {} has inconsistent value segment boundary ids","messagePattern":"history boundary (.+?) has inconsistent value segment boundary ids","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_events/src/history/mod.rs","lineNumber":613,"sourceCode":"        RunStatus::Cancelled => (None, None, completed.cancellation),\n        RunStatus::Pending\n        | RunStatus::Running\n        | RunStatus::WaitingForInput\n        | RunStatus::WaitingForEnv\n        | RunStatus::Cancelling => (None, None, None),\n    }\n}\n\nfn boundary_id_from_header_or_fallback(\n    fallback_dir: Option<&Path>,\n    header_boundary_ids: &[BoundaryId],\n    started: &RunStartedRecord,\n) -> io::Result<BoundaryId> {\n    if let Some(first) = header_boundary_ids.first().copied() {\n        if header_boundary_ids.iter().all(|id| *id == first) {\n            return Ok(first);\n        }\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            format!(\n                \"history boundary {} has inconsistent value segment boundary ids\",\n                fallback_dir\n                    .map(|dir| dir.display().to_string())\n                    .unwrap_or_else(|| \"byte segments\".to_string())\n            ),\n        ));\n    }\n    fallback_dir\n        .and_then(boundary_id_from_dir_name)\n        .ok_or_else(|| {\n            io::Error::new(\n                io::ErrorKind::InvalidData,\n                format!(\n                    \"history boundary for project {} omitted canonical boundary id\",\n                    started.request.project_id.0\n                ),","sourceCodeStart":595,"sourceCodeEnd":631,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_events/src/history/mod.rs#L595-L631","documentation":"boundary_id_from_header_or_fallback collects the boundary IDs stored in each .bamlvalue header; if they disagree (headers were written by different boundary sessions), it returns InvalidData instead of guessing. This detects mixed or interleaved segment files from multiple runs in one directory.","triggerScenarios":"Opening a boundary whose segment files' headers contain differing BoundaryIds — e.g. two recording runs wrote into the same directory, or segment files from one run were copied into another's directory.","commonSituations":"Reusing a temp/history directory across test runs without cleaning it; merging history directories manually; a clock/ordering bug causing two writers to share a dir.","solutions":["Clean the boundary directory and re-record so all segments come from one run.","Remove segment files whose header boundary ID differs from the run you want to replay.","Give each recording session its own unique directory.","Inspect .bamlvalue headers to identify which segments belong to which run."],"exampleFix":"// before\n// segments from two runs share one dir\nlet id = boundary_id_from_header_or_fallback(&segs, Some(&dir), &started)?;\n// after\nsegs.retain(|s| s.header_boundary_id == expected_id);\nlet id = boundary_id_from_header_or_fallback(&segs, Some(&dir), &started)?;","handlingStrategy":"validation","validationCode":"let ids: std::collections::HashSet<_> =\n    segments.iter().map(|s| s.header_boundary_id).collect();\nif ids.len() > 1 {\n    return Err(format!(\"mixed boundary ids in {}: {ids:?}\", dir.display()));\n}","typeGuard":null,"tryCatchPattern":"match open_boundary_from_segments(Some(&dir), &segments) {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidData => {\n        log::error!(\"{} mixes runs; re-record\", dir.display());\n        Err(e)\n    }\n    other => other,\n}","preventionTips":["Use a fresh, unique directory per recording run.","Clean history dirs between test runs before reusing them.","Never merge segment files from different runs into one directory."],"tags":["io","invalid-data","history","corruption"],"backgroundTag":"schema-validation-failed","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"}