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

API unable to paginate on files endpoint #22910

Closed
rlogiacco opened this issue Feb 14, 2023 · 1 comment · Fixed by #22921
Closed

API unable to paginate on files endpoint #22910

rlogiacco opened this issue Feb 14, 2023 · 1 comment · Fixed by #22921
Assignees
Labels
modifies/api This PR adds API routes or modifies them type/bug

Comments

@rlogiacco
Copy link

Description

When calling the GET /repos/{owner}/{repo}/pulls/{index}/files endpoint the MAX_RESPONSE_ITEMS config parameter is correctly respected, but also the MAX_GIT_DIFF_FILES config parameter is used and, if exceded, a index out of bounds error occurs.

All acceptable so far, but the pagination is also affected.

For example, with the following:

[git]
MAX_GIT_DIFF_FILES = 100
[api]
MAX_RESPONSE_ITEMS  = 100

With a PR containing 120 files, the first request to the endpoint correctly returns the first 100 items with an header X-HasMore: true. When performing a call to the same endpoint with a page=2 parameter, an error is produced:

...common/middleware.go:71:1() [E] [63ebf818] PANIC: runtime error: index out of range [100] with length 100

I would expect the API endpoint to ignore the MAX_GIT_DIFF_FILES param...

If this is the intended behaviour I suggest to introduce an additional configuration parameter to determine how many files are visbile through the UI.

I've created a test repo and a reference PR: https://try.gitea.io/rlogiacco/api-limit/pulls/1

Gitea Version

1.18.3

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

https://gist.github.com/rlogiacco/8a605132a73515f2c9277333a4e27b81

Screenshots

No response

Git Version

2.36.4

Operating System

official docker image

How are you running Gitea?

Inside a docker swarm using a a docker-compose file encompassing a mysql database

Database

MySQL

@techknowlogick techknowlogick added the modifies/api This PR adds API routes or modifies them label Feb 14, 2023
@sillyguodong
Copy link
Contributor

i am trying to fix it

lunny added a commit that referenced this issue Feb 20, 2023
…22921)

Close: #22910 

---
I'm confused about that why does the api (`GET
/repos/{owner}/{repo}/pulls/{index}/files`) require caller to pass the
parameters `limit` and `page`.
In my case, the caller only needs to pass a `skip-to` to paging. This is
consistent with the api `GET /{owner}/{repo}/pulls/{index}/files`
So, I deleted the code related to `listOptions`

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
modifies/api This PR adds API routes or modifies them type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants