Conversation
- TextConversions.AsDateTime / AsDateTimeOffset: use Double.TryParse with InvariantCulture instead of Double.Parse, and guard against values that would overflow DateTime/DateTimeOffset.AddMilliseconds (e.g. a /Date(9...9)/ string with hundreds of digits now returns None instead of throwing ArgumentOutOfRangeException). - Http.fs setHeaders Range case: fix error message to show the original header value (the 'value' variable) instead of the internal bytes array representation, which printed 'System.String[]' rather than the actual invalid value. - Add tests for overflow-safe ms-Date parsing in TextConversions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4 tasks
dsyme
approved these changes
Mar 18, 2026
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.
🤖 This is an automated pull request from Repo Assist, an AI assistant for this repository.
This PR fixes two small but genuine defensive-coding/error-reporting issues found during codebase investigation.
Changes
1.
TextConversions.AsDateTime/AsDateTimeOffset— overflow safetyAsDateTimeandAsDateTimeOffsetboth parsed the milliseconds portion of a Microsoft/Date(...)/timestamp usingDouble.Parsewithout any bounds check. For a string like/Date(9999...9)/with hundreds of digits,Double.ParsereturnsDouble.PositiveInfinity, which then causesDateTime.AddMilliseconds(Infinity)to throwArgumentOutOfRangeException— rather than returningNoneas callers expect from these "safe" conversion functions.Fix: Use
Double.TryParsewithInvariantCultureandNumberStyles.Integer, and guard againstDouble.IsInfinity; wrapAddMillisecondsin a try/catch forArgumentOutOfRangeException. The normal-range case (e.g./Date(1577836800000)/) is unaffected.2.
Http.fsRange header error messageWhen the Range header value has the wrong number of
--separated parts (e.g."bytes=0-100-200"), the error was:Here
bytesis astring[], so users would seeInvalid value for the Range header (System.String[])rather than the actual invalid input. Changed to usevalue(the original header string) with%s.Test Status
TextConversionstests: 25/25 pass, including two new overflow-safety assertions (/Date(9...9)/→None)