Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer Overflow Issue When Retrieving PR Reviews with Large PR Numbers [BUG]: #106

Closed
1 task done
Hossain2024 opened this issue Jul 29, 2024 · 2 comments
Closed
1 task done
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented

Comments

@Hossain2024
Copy link

Hossain2024 commented Jul 29, 2024

What happened?

I am encountering an issue when attempting to retrieve a list of reviews for pull requests. Specifically, when using certain PR numbers that returns review id numbers that exceed the maximum value for a 32-bit integer, the SDK throws an integer overflow error.

code snippet that produce the error:

var result = await _gitHubClient.Repos["microsoft"]["kiota"].Pulls[4602].GetAsync(x =>
 {
                x.QueryParameters.Page = 2;

  });

the error:

Unhandled exception. System.Text.Json.JsonException: The JSON value could not be converted to System.Int32. Path: $ | LineNumber: 0 | BytePositionInLine: 10.
 ---> System.FormatException: Either the JSON value is not in a supported format, or is out of bounds for an Int32.
   at System.Text.Json.ThrowHelper.ThrowFormatException(NumericType numericType)
   at System.Text.Json.Utf8JsonReader.GetInt32()
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   --- End of inner exception stack trace ---
   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 System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](JsonElement element, JsonTypeInfo`1 jsonTypeInfo) 
   at Microsoft.Kiota.Serialization.Json.JsonParseNode.GetIntValue()
   at GitHub.Models.PullRequestReview.<GetFieldDeserializers>b__58_6(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[T](ParsableFactory`1 factory)+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.Pulls.Item.Reviews.ReviewsRequestBuilder.GetAsync(Action`1 requestConfiguration, CancellationToken cancellationToken)
   at GitHubApiClient.FetchAllReviews(String owner, String reponame, Int32 PrNumber) in C:\Users\v-hossainma\Documents\repo-data-sync\src\GitHubApiClient.cs:line 97
   at Program.<Main>$(String[] args) in C:\Users\v-hossainma\Documents\repo-data-sync\src\Program.cs:line 37   at Program.<Main>(String[] args)

sample data that int that causes the issue: https://api.github.com/repos/microsoft/kiota/pulls/4602/reviews?page=2

 {
        "id": 2147902723,
        "node_id": "PRR_kwDOE0q91s6ABmUD",
        "user": {
            "login": "andrueastman",
            "id": 6464005,
            "node_id": "MDQ6VXNlcjY0NjQwMDU=",
            "avatar_url": "https://avatars.githubusercontent.com/u/6464005?u=3bf69774d9899535117f1bbebf1557be703fde1a&v=4",
            "gravatar_id": "",
            "url": "https://api.github.com/users/andrueastman",
            "html_url": "https://github.com/andrueastman",
            "followers_url": "https://api.github.com/users/andrueastman/followers",
            "following_url": "https://api.github.com/users/andrueastman/following{/other_user}",
            "gists_url": "https://api.github.com/users/andrueastman/gists{/gist_id}",
            "starred_url": "https://api.github.com/users/andrueastman/starred{/owner}{/repo}",
            "subscriptions_url": "https://api.github.com/users/andrueastman/subscriptions",
            "organizations_url": "https://api.github.com/users/andrueastman/orgs",
            "repos_url": "https://api.github.com/users/andrueastman/repos",
            "events_url": "https://api.github.com/users/andrueastman/events{/privacy}",
            "received_events_url": "https://api.github.com/users/andrueastman/received_events",
            "type": "User",
            "site_admin": false
        },

the integer 2147902723 causes an overflow since MaxValue = 2147483647 represents the max int32 value.

the Kiota open API spec: [raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/dereferenced/api.github.com.2022-11-28.deref.yaml]
(https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/dereferenced/api.github.com.2022-11-28.deref.yaml)
defines the id of the review id

responses:
        '200':
          description: The list of reviews returns in chronological order.
          content:
            application/json:
              schema:
                type: array
                items: &473
                  title: Pull Request Review
                  description: Pull Request Reviews are reviews on pull requests.
                  type: object
                  properties:
                    id:
                      description: Unique identifier of the review
                      example: 42
                      type: integer

looking into this the id should be an int64.

Versions

0.0.23

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Hossain2024 Hossain2024 added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Jul 29, 2024
Copy link

👋 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! 🚀

@kfcampbell
Copy link
Member

Thank you for reporting! This is fixed as of v0.0.24.

@github-project-automation github-project-automation bot moved this from 🆕 Triage to ✅ Done in 🧰 Octokit Active Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented
Projects
Archived in project
Development

No branches or pull requests

2 participants