[Bug]: hl panics on a relative --since or --until too far from now
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 87/100
Research direction
Read src/timeparse.rs at relative_past and relative_future, then check how their callers convert None into Error::UnrecognizedTime. Replace the overflowing time arithmetic with checked operations and verify that extreme --since and --until values return an error instead of panicking.
Written by the indexing model from the issue text.
Description
Observed
A relative time that reaches past the range of dates that hl can represent makes hl panic instead of reporting an error:
$ echo '{"ts":"2024-01-01T00:00:00Z","msg":"x"}' | hl --since -300000y -P
thread 'run' panicked at src/timeparse.rs:28:18:
`DateTime - TimeDelta` overflowed
--until +300000y does the same with +.
Expected
An error saying the time is out of range, as for any other value that --since and --until don't accept. A crash is a bug whatever the spec says. No spec covers relative times: specs/003-structured-logs/spec.md mentions --since and --until only for the format they take.
Where
relative_past and relative_future at src/timeparse.rs:25-41 add the duration to Utc::now() with the - and + operators of chrono, which panic on overflow. checked_sub_signed and checked_add_signed return None instead, which the callers already turn into Error::UnrecognizedTime.
clippy's unchecked_time_subtraction lint, enabled for #1890, covers only the std Instant and Duration types, so it doesn't catch this.
- Dominant language
- Rust
- Stars
- 3.3k
- Forks
- 67
- Avg merge
- 3h 4m
- Merged PRs (30d)
- 107
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pamburus/hl
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug resolved
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
pamburus/hl#1877 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
Similar issues
-
area:ui effort:medium enhancement P7 source:agent
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
marketing
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
documentation priority: low tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
nledford/Ladderback#1823 ·
Maintainers usually reply within 1 day
-
psmux-resurrect: restoring a session with a numeric name puts its windows into the wrong session (`new-window -t 4` is read as window 4)Possibly taken @ealwanlee claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
psmux/psmux-plugins#47 ·
-
Link Checker ReportOpenautomated issue report
Difficulty 1/5 Under an hour Newbie friendliness 76/100
ratatui/awesome-ratatui#598 ·
Maintainers usually reply within 1 day