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

[BUG]: Specifying PageCount doesn't work if the query gets constructed with page number as the first query parameter #2693

Closed
1 task done
corwin-gs opened this issue Apr 5, 2023 · 0 comments · Fixed by #2911
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@corwin-gs
Copy link

What happened?

I tried requesting 5 pages of file changes in a PR, for example:

var apiOptions = new ApiOptions
{
    PageCount = 5,
};
var pullRequest = await GitHubClient.PullRequest.Get(repoOwnerName, repositoryName, pullRequestNumber);

which actually requests all pages.

This is because of this code in Pagination.cs

return uri.Query.Split('&')
    .Select(keyValue =>
    {
        var indexOf = keyValue.IndexOf('=');
        if (indexOf > 0)
        {
            var key = keyValue.Substring(0, indexOf);
            var value = keyValue.Substring(indexOf + 1);
            return new KeyValuePair<string, string>(key, value);
        }

        //just a plain old value, return it
        return new KeyValuePair<string, string>(keyValue, null);
    })
    .ToDictionary(x => x.Key, x => x.Value);

which incorrectly includes the initial ?, which you can see the effect of in this debugger screenshot
image
and TryGetValue naturally returns false.

Versions

Octokit.net 5.0.2

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@corwin-gs corwin-gs added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Apr 5, 2023
@kfcampbell kfcampbell added Priority: Normal Status: Up for grabs Issues that are ready to be worked on by anyone and removed Status: Triage This is being looked at and prioritized labels Apr 10, 2023
@nickfloyd nickfloyd added the hacktoberfest Issues for participation in Hacktoberfest label Sep 20, 2023
andrew-from-toronto added a commit to andrew-from-toronto/octokit.net that referenced this issue Apr 23, 2024
kfcampbell added a commit that referenced this issue Apr 30, 2024
…age number as the first query parameter (#2911)

Fix #2693

Co-authored-by: Keegan Campbell <me@kfcampbell.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
Archived in project
3 participants