fix(cli): avoid panic on oversized --older-than durations - #1705
Merged
Merged
Conversation
CoverageTotal: 97.28% ⚪ 0 pp vs Comparing No per-file coverage changes vs 🔇 5 ignored region(s), 0 tolerated region(s)
Patch coveragePatch: 100% (13/13 new lines covered)
|
parse_since used the panicking chrono::Duration constructors and a plain DateTime subtraction, so an i64-valid but oversized --older-than (e.g. 100000000d or 9999999999999999w) crashed the process instead of returning the "invalid --older-than" error both `omni-dev log prune` and `omni-dev drive lease prune` already wrap around it. Switch to the checked try_* constructors and checked_sub_signed, and cover both overflow shapes (construction and subtraction) with a test. Fixes #1691
newhoggy
force-pushed
the
issue-1691-parse-since-panic
branch
from
September 17, 2026 15:49
b40d9cf to
7f6c226
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
parse_since(src/cli/log/query.rs) used the panickingchrono::Duration::seconds/minutes/hours/days/weeksconstructors andUtc::now() - dur, so an oversized buti64-valid--older-thancrashed the process instead of returning the documented "invalid --older-than" error.try_*fallible constructors andUtc::now() - durtochecked_sub_signed, mapping any overflow to ananyhowcontext error. Widened beyond the two reproduced shapes (d/w) to all units, sinces/m/hcan also overflow internally (e.g.Duration::minutes(i64::MAX)multiplies by 60).omni-dev log pruneandomni-dev drive lease prune, which both call this shared helper.Fixes #1691
Test plan
cargo test --lib cli::log::query— 25 passed, including newsince_rejects_oversized_durationcovering both overflow shapes from the issuecargo clippy --all-targets -- -D warnings— cleancargo fmt --check— clean