octokit / dotnet-sdk

MIT License
58 stars 8 forks source link

int32 overflow deserializing generated models #95

Closed martincostello closed 4 months ago

martincostello commented 4 months ago
          Looks like this also affects the new .NET SDK too:
System.Text.Json.JsonException
  HResult=0x80131500
  Message=The JSON value could not be converted to System.Int32. Path: $ | LineNumber: 0 | BytePositionInLine: 10.
  Source=System.Text.Json
  StackTrace:
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at Microsoft.Kiota.Serialization.Json.JsonParseNode.GetIntValue()
   at GitHub.Models.EnvironmentObject.<GetFieldDeserializers>b__42_3(IParseNode n)
   at Microsoft.Kiota.Serialization.Json.JsonParseNode.AssignFieldValues[T](T item)
   at Microsoft.Kiota.Serialization.Json.JsonParseNode.GetObjectValue[T](ParsableFactory`1 factory)
   at Microsoft.Kiota.Serialization.Json.JsonParseNode.<GetCollectionOfObjectValues>d__19`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at GitHub.Repos.Item.Item.Environments.EnvironmentsGetResponse.<GetFieldDeserializers>b__14_0(IParseNode n)
   at Microsoft.Kiota.Serialization.Json.JsonParseNode.AssignFieldValues[T](T item)
   at Microsoft.Kiota.Serialization.Json.JsonParseNode.GetObjectValue[T](ParsableFactory`1 factory)
   at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.<SendAsync>d__20`1.MoveNext()
   at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.<SendAsync>d__20`1.MoveNext()
   at GitHub.Repos.Item.Item.Environments.EnvironmentsRequestBuilder.<GetAsync>d__4.MoveNext()

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
FormatException: Either the JSON value is not in a supported format, or is out of bounds for an Int32.

Originally posted by @martincostello in https://github.com/octokit/octokit.net/issues/2893#issuecomment-2172718776

github-actions[bot] commented 4 months ago

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

martincostello commented 4 months ago

I'm still seeing this with 0.0.20 of GitHub.Octokit.SDK. Have created a new issue here as the original issue is resolved.

kfcampbell commented 4 months ago

Thanks for reporting! This should be fixed as of v0.0.21. Please let us know if you run into any cases where this isn't true! I'm going to close this issue for now, though please don't hesitate to report future occurrences.

martincostello commented 4 months ago

@kfcampbell Sorry, it's still broken. Looks like the exact property I have an issue with escaped the changes:

https://github.com/octokit/dotnet-sdk/blob/e4bb0f0bf57a34ed2fcc8b9911c5eb536e90a650/src/GitHub/Models/EnvironmentObject.cs#L34