Handle number overflow during parsing of min/max values#1480
Merged
baywet merged 1 commit intomicrosoft:vnextmicrosoft/OpenAPI.NET:vnextfrom Nov 22, 2023
Robulane:users/robulane/DontCrashRobulane/OpenAPI.NET:users/robulane/DontCrashCopy head branch name to clipboard
Merged
Handle number overflow during parsing of min/max values#1480baywet merged 1 commit intomicrosoft:vnextmicrosoft/OpenAPI.NET:vnextfrom Robulane:users/robulane/DontCrashRobulane/OpenAPI.NET:users/robulane/DontCrashCopy head branch name to clipboard
baywet merged 1 commit intomicrosoft:vnextmicrosoft/OpenAPI.NET:vnextfrom
Robulane:users/robulane/DontCrashRobulane/OpenAPI.NET:users/robulane/DontCrashCopy head branch name to clipboard
Conversation
baywet
approved these changes
Nov 22, 2023
Member
baywet
left a comment
There was a problem hiding this comment.
Thank you for the contribution!
pull bot
pushed a commit
to intensifier/Power-Fx
that referenced
this pull request
Nov 22, 2023
Update to get this fix: microsoft/OpenAPI.NET#1480
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.
Sometimes developers put Double.MaxValue or Long.MaxValue asmax values for numbers in json schema, even if their numbers are not expected to be that big/small. As we have already released the library with Decimal type for Max/Min, let's not introduce the breaking change and just fallback to Decimal.Max / Min in case of overflow. This should satisfy almost every scenario. We can revisit this if somebody really needs to have double or long here.
Fixing this exception stacktrace
ExceptionType: System.OverflowException
ExceptionMessage: Value was either too large or too small for a Decimal.
InnerExceptionType:
InnerExceptionMessage:
StackTrace:
at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
at System.Decimal.Parse(String s, NumberStyles style, IFormatProvider provider)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.<>c.<.cctor>b__83_141(OpenApiSchema o, ParseNode n)
at Microsoft.OpenApi.Readers.ParseNodes.PropertyNode.ParseField[T](T parentInstance, IDictionary
2 fixedFields, IDictionary2 patternFields)at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.LoadSchema(ParseNode node)
at Microsoft.OpenApi.Readers.ParseNodes.MapNode.<>c__DisplayClass6_0
1.<CreateMap>b__0(KeyValuePair2 n)at System.Linq.Enumerable.SelectEnumerableIterator
2.MoveNext() at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector)at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.<>c.<.cctor>b__83_158(OpenApiSchema o, ParseNode n)
at Microsoft.OpenApi.Readers.ParseNodes.PropertyNode.ParseField[T](T parentInstance, IDictionary
2 fixedFields, IDictionary2 patternFields)at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.LoadSchema(ParseNode node)
at Microsoft.OpenApi.Readers.V2.OpenApiV2VersionService.LoadElement[T](ParseNode node)
at Microsoft.OpenApi.Readers.ParsingContext.ParseFragment[T](YamlDocument yamlDocument, OpenApiSpecVersion version)
at Microsoft.OpenApi.Readers.OpenApiYamlDocumentReader.ReadFragment[T](YamlDocument input, OpenApiSpecVersion version, OpenApiDiagnostic& diagnostic)
at Microsoft.OpenApi.Readers.OpenApiTextReaderReader.ReadFragment[T](TextReader input, OpenApiSpecVersion version, OpenApiDiagnostic& diagnostic)
at Microsoft.OpenApi.Readers.OpenApiStringReader.ReadFragment[T](String input, OpenApiSpecVersion version, OpenApiDiagnostic& diagnostic)