API /issue endpoint returns pull requests #3516

Closed
opened 2025-11-02 05:15:36 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @jerrykan on GitHub (Jun 26, 2019).

  • Gitea version (or commit ref): 1.9.0+dev-377-g5908bb103
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

When making an API request to the /issues endpoint the items returned include both pull requests and issues, which causes the pagination links to not be accurate. This is probably related to #7297

In the example-repo2 there are 14 issues with 8 pull requests mixed in. Doing an API request with no query parameters returns the following headers:

curl -I -H  "accept: application/json" -H  "authorization: Basic XXXXXX" -X GET "https://try.gitea.io/api/v1/repos/jerrykan/example-repo2/issues"
HTTP/2 200 
content-type: application/json; charset=UTF-8
date: Wed, 26 Jun 2019 02:43:13 GMT
link: <https://try.gitea.io/api/v1/repos/jerrykan/example-repo2/issues?page=2>; rel="next",<https://try.gitea.io/api/v1/repos/jerrykan/example-repo2/issues?page=2>; rel="last"
set-cookie: XXXXXX
set-cookie: XXXXXX
set-cookie: XXXXXX
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN

Looking at the Link response header there should only be two pages of items to return. However when both pages are requested:

curl -s -H  "accept: application/json" -H  "authorization: Basic XXXXXX" -X GET "https://try.gitea.io/api/v1/repos/jerrykan/example-repo2/issues" | jq .[].title
"branch8"
"Issue 14"
"Issue 13"
"Issue 12"
"branch7"
"branch6"
"branch5"
"branch4"
"Issue 11"
"Issue 10"
curl -s -H  "accept: application/json" -H  "authorization: Basic XXXXXX" -X GET "https://try.gitea.io/api/v1/repos/jerrykan/example-repo2/issues?page=2" | jq .[].title
"Issue 9"
"Issue 8"
"Issue 7"
"Issue 6"
"branch3"
"branch2"
"branch1"
"Issue 5"
"Issue 4"
"Issue 3"

We can see that the branch* pull requests are included in the results, and that Issue 2 and Issue 1 are missing from the results

What I would expect is that no pull requests are included in the results, which would result in the Link response header URLs being correct.

Originally created by @jerrykan on GitHub (Jun 26, 2019). - Gitea version (or commit ref): 1.9.0+dev-377-g5908bb103 - Can you reproduce the bug at https://try.gitea.io: - [x] Yes (provide example URL) - [ ] No - [ ] Not relevant ## Description When making an API request to the `/issues` endpoint the items returned include both pull requests and issues, which causes the pagination links to not be accurate. This is probably related to #7297 In the [`example-repo2`](https://try.gitea.io/jerrykan/example-repo2/issues) there are 14 issues with 8 pull requests mixed in. Doing an API request with no query parameters returns the following headers: ``` curl -I -H "accept: application/json" -H "authorization: Basic XXXXXX" -X GET "https://try.gitea.io/api/v1/repos/jerrykan/example-repo2/issues" ``` ``` HTTP/2 200 content-type: application/json; charset=UTF-8 date: Wed, 26 Jun 2019 02:43:13 GMT link: <https://try.gitea.io/api/v1/repos/jerrykan/example-repo2/issues?page=2>; rel="next",<https://try.gitea.io/api/v1/repos/jerrykan/example-repo2/issues?page=2>; rel="last" set-cookie: XXXXXX set-cookie: XXXXXX set-cookie: XXXXXX x-content-type-options: nosniff x-frame-options: SAMEORIGIN ``` Looking at the `Link` response header there should only be two pages of items to return. However when both pages are requested: ``` curl -s -H "accept: application/json" -H "authorization: Basic XXXXXX" -X GET "https://try.gitea.io/api/v1/repos/jerrykan/example-repo2/issues" | jq .[].title ``` ``` "branch8" "Issue 14" "Issue 13" "Issue 12" "branch7" "branch6" "branch5" "branch4" "Issue 11" "Issue 10" ``` ``` curl -s -H "accept: application/json" -H "authorization: Basic XXXXXX" -X GET "https://try.gitea.io/api/v1/repos/jerrykan/example-repo2/issues?page=2" | jq .[].title ``` ``` "Issue 9" "Issue 8" "Issue 7" "Issue 6" "branch3" "branch2" "branch1" "Issue 5" "Issue 4" "Issue 3" ``` We can see that the `branch*` pull requests are included in the results, and that `Issue 2` and `Issue 1` are missing from the results What I would expect is that no pull requests are included in the results, which would result in the `Link` response header URLs being correct.
GiteaMirror added the type/bug label 2025-11-02 05:15:36 -06:00
Author
Owner

@stale[bot] commented on GitHub (Aug 25, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Aug 25, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@jerrykan commented on GitHub (Aug 25, 2019):

I believe this is still a valid bug

@jerrykan commented on GitHub (Aug 25, 2019): I believe this is still a valid bug
Author
Owner

@lunny commented on GitHub (Aug 25, 2019):

I marked #7299 bug because of pagination problem.

@lunny commented on GitHub (Aug 25, 2019): > I marked #7299 bug because of pagination problem.
Author
Owner

@lunny commented on GitHub (Aug 25, 2019):

I think we should close this one and keep #7297 open. Please feel free to reopen it.

@lunny commented on GitHub (Aug 25, 2019): I think we should close this one and keep #7297 open. Please feel free to reopen it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3516