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

Gitea: wrong pagination handling #5797

Closed
NateScarlet opened this issue Mar 27, 2020 · 0 comments · Fixed by #5798
Closed

Gitea: wrong pagination handling #5797

NateScarlet opened this issue Mar 27, 2020 · 0 comments · Fixed by #5798

Comments

@NateScarlet
Copy link
Contributor

NateScarlet commented Mar 27, 2020

let nextPage = parseInt(url.query.page as string, 10) || 1 + 1;
while (total && pc.length < total) {
nextPage += 1;

when url.query.page is undefined , NaN || 1 + 1 is equivalent to NaN || 2, so nextPage starts from 3.

I have 26 repo, gitea default repo search page size is 10, so repo 21-26 got executed multiple times, and repo 11-20 will never got executed.

## Fix

let nextPage = parseInt(url.query.page || '1', 10)

then throw a error when nextPage is NaN.

seems modify url.query won't affect URL.format result

> u = URL.parse('https://git.example.com/api/v1/repos/search?uid=1', true)
Url {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'git.example.com',
  port: null,
  hostname: 'git.example.com',
  hash: null,
  search: '?uid=1',
  query: [Object: null prototype] { uid: '1' },
  pathname: '/api/v1/repos/search',
  path: '/api/v1/repos/search?uid=1',
  href: 'https://git.example.com/api/v1/repos/search?uid=1' }
> u.query.page = '1'
'1'
> URL.format(u)
'https://git.example.com/api/v1/repos/search?uid=1'

I have 26 repo, gitea default repo search page size is 10, so repo 1-10 got executed 3 times, and repo 11-26 will never got executed.

NateScarlet added a commit to NateScarlet/renovate that referenced this issue Mar 27, 2020
rarkins pushed a commit that referenced this issue Mar 27, 2020
ViralRuparel pushed a commit to ViralRuparel/renovate that referenced this issue Mar 29, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant