{"record":{"id":"bcdac1fa21cdb4b2","repo":"rtk-ai/rtk","slug":"unexpected-end-of-stream","errorCode":null,"errorMessage":"unexpected end of stream","messagePattern":"unexpected end of stream","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/cmds/dotnet/binlog.rs","lineNumber":580,"sourceCode":"    cursor: Cursor<&'a [u8]>,\n}\n\nimpl<'a> BinReader<'a> {\n    fn new(bytes: &'a [u8]) -> Self {\n        Self {\n            cursor: Cursor::new(bytes),\n        }\n    }\n\n    fn is_eof(&self) -> bool {\n        (self.cursor.position() as usize) >= self.cursor.get_ref().len()\n    }\n\n    fn read_exact(&mut self, len: usize) -> Result<&'a [u8]> {\n        let start = self.cursor.position() as usize;\n        let end = start.saturating_add(len);\n        if end > self.cursor.get_ref().len() {\n            anyhow::bail!(\"unexpected end of stream\");\n        }\n        self.cursor.set_position(end as u64);\n        Ok(&self.cursor.get_ref()[start..end])\n    }\n\n    fn skip(&mut self, len: usize) -> Result<()> {\n        let _ = self.read_exact(len)?;\n        Ok(())\n    }\n\n    fn read_u8(&mut self) -> Result<u8> {\n        Ok(self.read_exact(1)?[0])\n    }\n\n    fn read_bool(&mut self) -> Result<bool> {\n        Ok(self.read_u8()? != 0)\n    }\n","sourceCodeStart":562,"sourceCodeEnd":598,"githubUrl":"https://github.com/rtk-ai/rtk/blob/36788f6bd4932037caac5cbb1d15d6e2fb9f33da/src/cmds/dotnet/binlog.rs#L562-L598","documentation":"BinReader::read_exact attempts to take `len` bytes at the current cursor and the requested range extends past the end of the in-memory buffer. All primitive readers (skip, read_u8, read_i32_le, read_i64_le, read_dotnet_string) funnel through it, so any truncated read surfaces as this error.","triggerScenarios":"Any decode step in parse_events_from_binlog whose declared length exceeds remaining bytes — a record/event/string length pointing beyond EOF, i.e. truncated or misaligned payload.","commonSituations":"Binlog truncated by crash/disk-full/interrupted copy; misaligned parse after corrupt data; passing a non-binlog file whose bytes don't match declared sizes.","solutions":["Regenerate the binlog — the current file is truncated or corrupt","Verify expected file size vs actual (compare with CI artifact checksum)","Confirm the file is a real binlog, not an arbitrary file passed by mistake"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match parse_events_from_binlog(&path) {\n    Ok(b) => use_events(&b),\n    Err(e) if e.to_string().contains(\"unexpected end of stream\") => {\n        eprintln!(\"binlog truncated; rerun the build to regenerate it\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Wait for build completion before consuming the binlog (file locks/completion markers)","Verify artifact size/checksum after transfer","Enable atomic file writes (write temp then rename) in your build scripts"],"tags":["dotnet","binlog","truncation","deserialization"],"backgroundTag":"unexpected-end-of-stream","analyzedSha":"36788f6bd4932037caac5cbb1d15d6e2fb9f33da","analyzedAt":"2026-09-03T16:33:57.738Z","contentChangedAt":"2026-09-03T16:33:57.738Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}