{"record":{"id":"4199255865c03711","repo":"rtk-ai/rtk","slug":"invalid-7-bit-encoded-integer","errorCode":null,"errorMessage":"invalid 7-bit encoded integer","messagePattern":"invalid 7-bit encoded integer","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/cmds/dotnet/binlog.rs","lineNumber":623,"sourceCode":"        let b = self.read_exact(8)?;\n        Ok(i64::from_le_bytes([\n            b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7],\n        ]))\n    }\n\n    fn read_7bit_i32(&mut self) -> Result<i32> {\n        let mut value: u32 = 0;\n        let mut shift = 0;\n        loop {\n            let byte = self.read_u8()?;\n            value |= ((byte & 0x7F) as u32) << shift;\n            if (byte & 0x80) == 0 {\n                return Ok(value as i32);\n            }\n\n            shift += 7;\n            if shift >= 35 {\n                anyhow::bail!(\"invalid 7-bit encoded integer\");\n            }\n        }\n    }\n\n    fn read_dotnet_string(&mut self) -> Result<String> {\n        let len = self.read_7bit_i32()?;\n        if len < 0 {\n            anyhow::bail!(\"negative string length: {}\", len);\n        }\n        let bytes = self.read_exact(len as usize)?;\n        String::from_utf8(bytes.to_vec()).context(\"invalid UTF-8 string\")\n    }\n}\n\npub fn scrub_sensitive_env_vars(input: &str) -> String {\n    SENSITIVE_ENV_RE\n        .replace_all(input, \"${prefix}[REDACTED]\")\n        .into_owned()","sourceCodeStart":605,"sourceCodeEnd":641,"githubUrl":"https://github.com/rtk-ai/rtk/blob/36788f6bd4932037caac5cbb1d15d6e2fb9f33da/src/cmds/dotnet/binlog.rs#L605-L641","documentation":"read_7bit_i32 decodes a 7-bit variable-length integer; if it still hasn't seen a terminating byte after 5 bytes (shift >= 35), the encoding is invalid for an i32 and parsing bails. This signals misaligned/corrupt stream data at the string-reading site.","triggerScenarios":"read_dotnet_string calls read_7bit_i32 on bytes that are not a valid 7-bit-encoded length — the cursor is in the middle of arbitrary data (misalignment from earlier corruption) or the file is not a binlog.","commonSituations":"Parsing corrupted/truncated binlogs; passing random binary or text files as .binlog; version mismatch causing a wrong offset interpretation.","solutions":["Regenerate the binlog from a clean build","Verify the input file is a genuine .binlog (magic header) before parsing","If reproducible on a file that opens in Structured Log Viewer, file a parser bug with the offending record"],"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(\"invalid 7-bit encoded integer\") => {\n        eprintln!(\"binlog stream corrupt; regenerate the log\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Validate the binlog magic header before parsing","Regenerate corrupt logs rather than retrying","Report reproducible failures with the offending file to the tool maintainers"],"tags":["dotnet","binlog","corruption","deserialization"],"backgroundTag":"corrupt-or-truncated-log-file","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"}