Repository navigation
Reject --for durations longer than a wait can take - #15
Merged
Merged
Conversation
DurationParser accepted anything up to TimeSpan.MaxValue, but the console runner's ManualResetEventSlim.Wait and the tray's timer both throw past int.MaxValue milliseconds (about 24.8 days), so `--for 25d` started the tool and then crashed it with an unhandled exception. Cap TryParse at DurationParser.MaxDuration, and have the command line report a too-long value as a usage error rather than as "not a duration". Fixes #14 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CGpRxGxuvhstHo5zXQoWSA
|
3 tasks
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.



Fixes #14
What changed
DurationParserused to accept any positive duration up toTimeSpan.MaxValue.ConsoleRunner.Run'sManualResetEventSlim.Wait(TimeSpan)and the tray'sDispatcherTimerboth reject anything overint.MaxValuems (about 24.8 days). As a result,--for 25dprinted its start message and then crashed with an unhandledArgumentOutOfRangeException.DurationParser.MaxDurationisTimeSpan.FromMilliseconds(int.MaxValue).TryParsenow returnsfalsefor anything longer, so both the console path and the tray path are covered.DurationParser.TryParseAnyLengthholds the unbounded parse.CommandLineParseruses it so it can tell "too long" apart from "not a duration".--for 25dnow fails at argument parsing with'25d' is too long: --for can be at most 24 days.MaxDurationis a new public member. The change is additive, and the package-validation build passes.Tests
DurationParserTests:24dstill parses.25dand24d21h(just past the limit) are rejected.MaxDuration_IsTheLongestTimeoutAWaitTakeschecks the boundary against a realManualResetEventSlim: a wait ofMaxDurationis accepted, and a wait ofMaxDuration + 1msthrows.CommandLineParserTests.TryParse_WithADurationLongerThanATimerCanWait_FailsWithAUsageErrorcovers the usage message.With the cap temporarily removed, the three new rejection tests fail. With it in place, the full suite passes on Linux/net10.0: 117 passed, 1 skipped.
🤖 Generated with Claude Code
https://claude.ai/code/session_01CGpRxGxuvhstHo5zXQoWSA
Generated by Claude Code