#6111: fix: detect float underflow in duration parsing
cli
Cluster:
Backoff and Duration Tests
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adds an additional validation step to `parseDurationMs` (`src/cli/parse-duration.ts`) that throws when the computed duration rounds to `0ms` even though the parsed numeric value is non-zero. The goal is to detect cases where floating-point underflow or precision loss causes an otherwise-valid duration to collapse to zero after conversion and rounding.
The change is localized to the CLI duration parsing helper and impacts all call sites that rely on this shared parsing logic (e.g., agent runtime config validation and various CLI commands that accept duration flags).
<h3>Confidence Score: 4/5</h3>
- This PR is generally safe to merge but may introduce unintended rejections of sub-millisecond durations that previously parsed to 0ms.
- The change is small and easy to reason about, but the new `ms === 0 && value !== 0` guard will fire for any value that legitimately rounds to 0ms (not just float underflow), which could be behavior-breaking for callers that allow very small durations.
- src/cli/parse-duration.ts
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#4137: [AI-assisted] test(cli): add missing test cases for parseDurationMs
by sind00 · 2026-01-29
76.6%
#9114: Fix: Reduce NO_TIMEOUT_MS to 24 days to avoid Node.js overflow warning
by vishaltandale00 · 2026-02-04
74.0%
#11416: fix: clamp timeout values to avoid 32-bit overflow warning
by seojoonkim · 2026-02-07
73.9%
#4095: Test/add format duration tests
by TechWizard9999 · 2026-01-29
73.4%
#11421: Tests: add unit tests for infra/format-duration
by PythonUser42 · 2026-02-07
72.5%
#15754: fix: handle Unix timestamps in seconds in parseAbsoluteTimeMs
by MisterGuy420 · 2026-02-13
72.3%
#11178: fix: use Number.parseInt with explicit radix in parseDateToMs
by Yida-Dev · 2026-02-07
71.3%
#15784: fix: timestamp parsing should convert seconds to milliseconds
by murasame-desu-ai · 2026-02-13
70.9%
#12477: fix(agents): prevent TimeoutOverflowWarning when timeout is disabled
by skylarkoo7 · 2026-02-09
69.7%
#8661: fix: display rate limit errors correctly instead of as context over...
by dbottme · 2026-02-04
69.6%