{"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/0924356b4caba4989607227b7c8824d3d8098719/src/cmds/dotnet/binlog.rs#L605-L641","documentation":"Raised by `read_7bit_i32` while decoding a .NET 7-bit variable-length (LEB128-style) integer: after shifting 35+ bits (more than 5 continuation bytes) the encoder still has not produced a terminating byte with the high bit clear. A valid 7-bit-encoded Int32 never exceeds 5 bytes, so this indicates corrupt data or a desynchronized read cursor. It is thrown from `read_dotnet_string` when decoding the string length prefix.","triggerScenarios":"`read_dotnet_string` calls `read_7bit_i32` on bytes that are not a valid 7-bit encoding — e.g. 5+ consecutive bytes with the 0x80 bit set — typically because the cursor is misaligned or the buffer is not binlog data.","commonSituations":"Parsing a file that is not a real .binlog (wrong file passed); cursor misalignment after an earlier record was misparsed (format-version mismatch with a newer .NET SDK); corruption in the middle of a binlog; reading a partially flushed log.","solutions":["Confirm the input file is a genuine Binary Log produced by `dotnet build -bl`; regenerate it if in doubt.","Check that earlier records were parsed with correct offsets — a misaligned cursor makes every subsequent 7-bit decode garbage; upgrade the reader if the binlog came from a newer SDK.","Validate the decoded length immediately (see 'negative string length') and treat encoder failures as input corruption, aborting parse with context.","Fall back to passthrough/raw output instead of failing the command when binlog parsing fails."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// sanity-check before decoding: ensure at least 1 byte remains and\n// cap the string-length prefix region to what the buffer can hold\nfn can_decode_7bit(buf: &[u8], pos: usize) -> bool {\n    pos < buf.len() && buf[pos..].iter().take(5).count() > 0\n}","typeGuard":null,"tryCatchPattern":"match read_dotnet_string(reader) {\n    Ok(s) => s,\n    Err(e) if e.to_string().contains(\"invalid 7-bit encoded integer\") => {\n        eprintln!(\"binlog cursor desynchronized at offset {}\", offset);\n        abort_parse_with_fallback()\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Verify earlier record parses succeeded — a misaligned cursor corrupts every subsequent 7-bit decode.","Confirm the input is a real binlog (magic bytes) before decoding strings.","Cap look-ahead to 5 bytes when decoding so you fail fast on runaway continuation bytes.","Test the parser against binlogs from the .NET SDK versions you actually use."],"tags":["dotnet","binlog","parse-error","corrupt-data"],"backgroundTag":"invalid-argument-format","analyzedSha":"0924356b4caba4989607227b7c8824d3d8098719","analyzedAt":"2026-09-19T19:25:29.612Z","contentChangedAt":"2026-09-19T19:25:29.612Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}