-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Description
We have a repository with a total of 43 tags, which is also reflected correctly in Gitea's UI, both on the repo's main page header, as well as the Releases tab. However, performing an HTTP GET to /api/v1/repos/org-name/repo-name/tags
yields an array containing only 29 entries, and the X-Total-Count
header also has a value of 29.
I tracked the relevant Gitea code down to the function GetTagInfos
:
Line 108 in de4ab41
From that, we can construct the Git command and write its output to a file (gitrefs.txt):
git for-each-ref --format="objecttype %(objecttype)%00refname:lstrip=2 %(refname:lstrip=2)%00object %(object)%00objectname %(objectname)%00creator %(creator)%00contents %(contents)%00contents:signature %(contents:signature)%00%00" --sort '-*creatordate' refs/tags >gitrefs.txt
Looking at gitrefs.txt I could see that the 29 tags returned are exactly the first 29 entries in gitrefs.txt. The 30th tag and beyond are not included in Gitea's API response. The 30th commit has a very long commit message >100 kiB, which is an unfortunate result of our release process, but we are unable to change this retroactively.
I tracked the source of the problem further to this line:
gitea/modules/git/foreachref/parser.go
Line 72 in de4ab41
When p.scanner.Scan()
returns false, p.scanner.Err()
should be checked, which is not currently done. I patched it locally, ran it on gitrefs.txt, and voilá, it prints "bufio.Scanner: token too long" due to the default 64 kiB internal buffer in bufio.Scanner
, which is too small for the offending tag's commit message.
Demo:
- UI shows 3 tags: https://demo.gitea.com/meyfa-lawo/tags-foreachref/tags
- API shows just the first tag: https://demo.gitea.com/api/v1/repos/meyfa-lawo/tags-foreachref/tags
Gitea Version
1.24.3
Can you reproduce the bug on the Gitea demo site?
Yes
Log Gist
No response
Screenshots
Log of the GET request, which returns 200 OK because the error is never checked:
Jul 25 15:51:20 REDACTED docker[REDACTED]: 2025年07月25日 13:51:20 HTTPRequest [I] router: completed GET /api/v1/repos/REDACTED/REDACTED/tags for 172.17.0.1:33324, 200 OK in 11.9ms @ repo/tag.go:25(repo.ListTags)
Git Version
2.49.1
Operating System
Linux (amd64)
How are you running Gitea?
Prebuilt official OCI image
Database
SQLite