{"record":{"id":"65faa332af893095","repo":"rtk-ai/rtk","slug":"negative-record-length","errorCode":null,"errorMessage":"negative record length: {}","messagePattern":"negative record length: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/cmds/dotnet/binlog.rs","lineNumber":353,"sourceCode":"            .read_7bit_i32()\n            .context(\"failed to read record kind\")?;\n        if kind == RECORD_END_OF_FILE {\n            break;\n        }\n\n        match kind {\n            RECORD_STRING => {\n                let text = reader\n                    .read_dotnet_string()\n                    .context(\"failed to read string record\")?;\n                parsed.string_records.push(text);\n            }\n            RECORD_NAME_VALUE_LIST | RECORD_PROJECT_IMPORT_ARCHIVE => {\n                let len = reader\n                    .read_7bit_i32()\n                    .context(\"failed to read record length\")?;\n                if len < 0 {\n                    anyhow::bail!(\"negative record length: {}\", len);\n                }\n                reader\n                    .skip(len as usize)\n                    .context(\"failed to skip auxiliary record payload\")?;\n            }\n            _ => {\n                let len = reader\n                    .read_7bit_i32()\n                    .context(\"failed to read event length\")?;\n                if len < 0 {\n                    anyhow::bail!(\"negative event length: {}\", len);\n                }\n\n                let payload = reader\n                    .read_exact(len as usize)\n                    .context(\"failed to read event payload\")?;\n                let mut event_reader = BinReader::new(payload);\n                let _ =","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/rtk-ai/rtk/blob/36788f6bd4932037caac5cbb1d15d6e2fb9f33da/src/cmds/dotnet/binlog.rs#L335-L371","documentation":"While scanning auxiliary records (NameValueList / ProjectImportArchive), the record's 7-bit-encoded length reads as a negative i32. Binlog record lengths are unsigned quantities, so a negative value means the parser has desynchronized from the stream.","triggerScenarios":"parse_events_from_binlog encounters RECORD_NAME_VALUE_LIST or RECORD_PROJECT_IMPORT_ARCHIVE whose encoded length decodes negative — nearly always from a corrupted or truncated payload, or reading a file whose claimed length ran past the buffer.","commonSituations":"Binlog damaged by partial download/copy; file truncated mid-write; feeding a non-binlog file to the parser so offsets land mid-data.","solutions":["Regenerate the binlog — treat the existing file as corrupt","Confirm the build that produced it completed and flushed the file (no kill/disk-full)","Check the file is a real binlog (magic header present) and not an arbitrary file","If reproducible with a valid file, report the parser bug at the producing record boundary"],"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(\"negative record length\") => {\n        eprintln!(\"binlog corrupt; falling back to raw dotnet output\");\n        run_raw_dotnet(args)\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Verify artifact checksums before parsing","Never truncate/kill a build mid-write","Regenerate the binlog instead of retrying a corrupt file"],"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-14T00:17:10.932Z"}