{"id":"88f71d8ccccb82af","repo":"rust-lang/cargo","slug":"no-timing-data-found-in-log","errorCode":null,"errorMessage":"no timing data found in log","messagePattern":"no timing data found in log","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/ops/cargo_report/timings.rs","lineNumber":351,"sourceCode":"                    e.get_mut().data.duration = elapsed;\n                    e.get_mut().data.unblocked_units = unblocked;\n                }\n                Entry::Vacant(_) => {\n                    tracing::warn!(\"unit {index} ended, but it has no start recorded\");\n                }\n            },\n            _ => {} // skip non-timing logs\n        }\n    }\n\n    // A build can legitimately have no units at all, such as an idle\n    // `cargo test` with `test = false` and `doctest = false`,\n    // so `--timings` always renders its report.\n    // `cargo report timings` instead treats a unit-less\n    // log as corrupted or truncated and errors out.\n    // See https://github.com/rust-lang/cargo/issues/17212.\n    if error_if_no_units && units.is_empty() {\n        anyhow::bail!(\"no timing data found in log\");\n    }\n\n    ctx.root_units = {\n        let mut root_map: IndexMap<_, Vec<_>> = IndexMap::default();\n        for index in requested_units {\n            let unit = &units[&index];\n            // Pretty much like `workspace::Target::description_named`\n            let target_desc = if unit.target.kind == \"lib\" {\n                \"lib\".to_owned()\n            } else if unit.target.kind == \"build-script\" {\n                \"build script\".to_owned()\n            } else {\n                format!(r#\" {} \"{}\"\"#, unit.target.name, unit.target.kind)\n            };\n            root_map.entry(index).or_default().push(target_desc);\n        }\n        root_map\n            .into_iter()","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/ops/cargo_report/timings.rs#L333-L369","documentation":"Inside prepare_context, `cargo report timings` collects timing records per build unit. When the log parses but contains zero units (error_if_no_units is true for the report path), it bails at timings.rs:351. Unlike the live `--timings` flag (which happily renders an empty report), the report command treats a unit-less log as corrupted/truncated, per rust-lang/cargo#17212.","triggerScenarios":"Running `cargo report timings` against a log from a build that compiled nothing (e.g. `cargo test` with test=false and doctest=false), or a log that was truncated/corrupted mid-write.","commonSituations":"Pointing --id at an idle/no-op build session; cargo crashed mid-build leaving a partial log; log file manually edited.","solutions":["Re-run a real build with `-Z build-analysis` that actually compiles units, then report against that session.","Use `cargo report sessions` to pick a session known to have done work.","If the log is corrupted, delete it from the log directory and regenerate."],"exampleFix":"# before - report against an idle session\n$ cargo report timings --id <idle-id>\nerror: no timing data found in log\n\n# after - build something then report\n$ cargo +nightly build -Z build-analysis\n$ cargo +nightly report timings","handlingStrategy":"validation","validationCode":"# Heuristic: reject obviously empty/truncated logs (no timing records):\nlog=\"$1\"\nif ! grep -q '\"kind\"' \"$log\" 2>/dev/null; then\n  echo \"log has no build-unit records; rebuild with -Z build-analysis\" >&2\n  exit 1\nfi\ncargo report timings --id \"$(basename \"$log\")\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Report against a session that actually compiled units.","Use `cargo report sessions` to pick a non-idle --id.","Delete corrupted/partial logs and regenerate with a fresh build."],"tags":["report","timings","build-analysis","corrupted-log"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}