From afa7733c69856cc2e5efa79ef6e5992e1228352a Mon Sep 17 00:00:00 2001 From: rootkiller6788 Date: Thu, 20 Aug 2026 12:36:36 +0800 Subject: [PATCH] Fix raw debug output for negative estimated end durations When an experiment's completed job count exceeds its expected total (e.g. after jobs are retried), the "estimated end" duration computed in endpoint_experiment becomes negative. chrono::Duration::to_std() rejects negative durations, so humanize() fell back to the raw Debug formatting, producing output like `TimeDelta { secs: -1, nanos: 884994194 }` on the experiment page. Report such durations as "0 seconds" instead of leaking the internal TimeDelta representation. --- src/server/routes/ui/experiments.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/server/routes/ui/experiments.rs b/src/server/routes/ui/experiments.rs index 67e469bc..5ce18711 100644 --- a/src/server/routes/ui/experiments.rs +++ b/src/server/routes/ui/experiments.rs @@ -130,8 +130,11 @@ fn humanize(duration: Duration) -> String { let duration = match duration.to_std() { Ok(d) => d, Err(_) => { - // Don't try to make it pretty as a fallback. - return format!("{duration:?}"); + // A negative duration (e.g. the "estimated end" of an experiment + // whose jobs have all finished but not yet been cleaned up) can't be + // converted to a `std::time::Duration`. Report it as zero instead of + // the raw `TimeDelta { secs: -1, ... }` debug output. + return "0 seconds".to_string(); } }; if duration.as_secs() < 60 {