Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tags API returns incomplete array if any tag's commit message is too long #35221

Closed
Labels
Milestone
@meyfa-lawo

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:

func (repo *Repository) GetTagInfos(page, pageSize int) ([]*Tag, int, error) {

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:

if !p.scanner.Scan() {

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /