{"record":{"id":"a75d843fa110b9b8","repo":"rtk-ai/rtk","slug":"failed-to-parse-binlog-at-empty-file","errorCode":null,"errorMessage":"Failed to parse binlog at {}: empty file","messagePattern":"Failed to parse binlog at (.+?): empty file","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/cmds/dotnet/binlog.rs","lineNumber":303,"sourceCode":"    project_files: HashSet<String>,\n    errors: Vec<BinlogIssue>,\n    warnings: Vec<BinlogIssue>,\n    build_succeeded: Option<bool>,\n    build_started_ticks: Option<i64>,\n    build_finished_ticks: Option<i64>,\n}\n\n#[derive(Default)]\nstruct ParsedEventFields {\n    message: Option<String>,\n    timestamp_ticks: Option<i64>,\n}\n\nfn parse_events_from_binlog(path: &Path) -> Result<ParsedBinlog> {\n    let bytes = std::fs::read(path)\n        .with_context(|| format!(\"Failed to read binlog at {}\", path.display()))?;\n    if bytes.is_empty() {\n        anyhow::bail!(\"Failed to parse binlog at {}: empty file\", path.display());\n    }\n\n    let mut decoder = GzDecoder::new(bytes.as_slice());\n    let mut payload = Vec::new();\n    decoder.read_to_end(&mut payload).with_context(|| {\n        format!(\n            \"Failed to parse binlog at {}: gzip decode failed\",\n            path.display()\n        )\n    })?;\n\n    let mut reader = BinReader::new(&payload);\n    let file_format_version = reader\n        .read_i32_le()\n        .context(\"binlog header missing file format version\")?;\n    let _minimum_reader_version = reader\n        .read_i32_le()\n        .context(\"binlog header missing minimum reader version\")?;","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/rtk-ai/rtk/blob/36788f6bd4932037caac5cbb1d15d6e2fb9f33da/src/cmds/dotnet/binlog.rs#L285-L321","documentation":"This error is thrown when a .binlog file exists but has zero bytes. parse_events_from_binlog reads the whole file first and bails out early because an empty buffer cannot contain the binlog magic header, let alone any build events.","triggerScenarios":"Calling rtk dotnet build/test/restore (which invoke parse_build/parse_test/parse_restore) with a .binlog path that points to a 0-byte file — e.g. the logger was attached but MSBuild crashed before writing anything, or the file was truncated by disk-full/cleanup.","commonSituations":"MSBuild launched with /bl but killed before flush; antivirus or a cleaner truncated the file; a wrapper script created the file but the build failed instantly; passing the wrong path variable that happens to be an empty touched file.","solutions":["Delete and regenerate the binlog by re-running the build/test with /bl (or rtk's wrapping command)","Check disk space and that no external process truncates the file","Verify the file with `ls -l` / `wc -c` to confirm it is genuinely 0 bytes and not a path mistake","Run with rtk proxy or raw dotnet to confirm the underlying build itself succeeds"],"exampleFix":"// before: parsing a possibly-empty file blindly\nlet binlog = parse_events_from_binlog(&path)?;\n// after: guard before calling\nif path.metadata()?.len() == 0 { eprintln!(\"binlog is empty, rerun build with /bl\"); } else { let binlog = parse_events_from_binlog(&path)?; }","handlingStrategy":"validation","validationCode":"use std::path::Path;\nfn binlog_is_parseable(path: &Path) -> std::io::Result<bool> {\n    Ok(path.metadata()?.len() > 0)\n}","typeGuard":null,"tryCatchPattern":"match parse_events_from_binlog(&path) {\n    Ok(binlog) => use_events(&binlog),\n    Err(e) if e.to_string().contains(\"empty file\") => {\n        eprintln!(\"binlog {} is empty; rerun the build with /bl\", path.display());\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Check file size > 0 before parsing","Ensure builds with /bl complete and are never killed mid-write","Monitor disk space in CI","Treat 0-byte artifacts as build failures in the pipeline"],"tags":["dotnet","binlog","file-io","empty-input"],"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"}