Skip to content

Reduce paging inconsistency #34561

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ChristopherHX
Copy link
Contributor

@ChristopherHX ChristopherHX commented May 28, 2025

This is an paging inconsistency api review, please comment your opinion about the added code comments

  • ctx.SetLinkHeader(int(totalNumOfBranches), listOptions.PageSize) missing for several api endpoints should I add them everywhere?

  • do we want to accept per_page in api?

    • better compatibility with existing keda github_runner
    • Otherwise I am 100% required to create a new provider, since it does not use paging
    • well this would add 20 entries, otherwise someone needs to set maximum to 100 for full GH Compat
  • GetListOptions replaced almost all custom paging parsing of the rest api

  • Should callers that expect page=0 to bypass paging be updated to use Listall constant?

* disallow bypassing configured limits in api
* allow per_page without documenting it
* allow limit for the only endpoint only allowing per_page

This is an paging inconsistency api review, please comment your opinion about the added code comments

* 	ctx.SetLinkHeader(int(totalNumOfBranches), listOptions.PageSize) missing for several api endpoints should I add them everywhere?

* do we want to accept per_page in api?
  * better compatibility with existing keda github_runner
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 28, 2025
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels May 28, 2025
@ChristopherHX ChristopherHX added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label May 28, 2025
return watches, sess.Find(&watches)
}
watches := make([]*IssueWatch, 0, 8)
listOptions.SetDefaultValues()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new logic will force the pagination but the pagination could be ignored in the old logic.

Copy link
Contributor Author

@ChristopherHX ChristopherHX Jun 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the pagination could be ignored in the old logic.

Yes this is exactly one of the inconsistencies, I want to discuss in this PR.

IMO Someone could abuse disabled paging of the rest api controlled by the api client. For reference this function is only used in the Rest Api and TestCode, nowhere else. Where UI code is calling them as well, I only added comments.

Make Gitea do expensive database queries, without constraints.

Other than that SetDefaultValues is not needed here, since SetSessionPagination calls this function.

Suggested change
listOptions.SetDefaultValues()

If this is an expected feature, we should add tests that verifies GET /repos/{owner}/{repo}/issues/{index}/subscriptions can bypass paging by specifing the page as 0 or not including it in the query.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not against most of the changes. Maybe we should mark this as break.

@ChristopherHX ChristopherHX added the pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! label Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants