Skip to content

API unable to paginate on files endpoint #22910

@rlogiacco

Description

@rlogiacco

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

Activity

sillyguodong

sillyguodong commented on Feb 15, 2023

@sillyguodong
Contributor

i am trying to fix it

added a commit that references this issue on Feb 20, 2023
36d1d5f
locked and limited conversation to collaborators on May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

modifies/apiThis PR adds API routes or modifies themtype/bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @techknowlogick@rlogiacco@sillyguodong

    Issue actions

      API unable to paginate on files endpoint · Issue #22910 · go-gitea/gitea