Skip to content

API endpoint /org/{org}/teams doesn't provide Link header for pagination #36516

@laumann

Description

@laumann

Description

As the title says, the Link header does not appear to be provided on the API route /org/{org}/teams. The limit and page parameters are respected.

Below is a snippet where I've dumped the headers for /repos/gentoo/gentoo/pulls and /orgs/bork/teams (bork being my test org). Notice the Access-Control-Expose-Headers does not include Link in the second request

>>> url = https://codeberg.org/api/v1/repos/gentoo/gentoo/pulls?state=all&limit=3
{'Access-Control-Expose-Headers': 'Link, X-Total-Count', 'Alt-Svc': 'h3=":443"; ma=2592000,h3=":443"; ma=2592000', 'Cache-Control': 'max-age=0, private, must-revalidate, no-transform', 'Content-Type': 'application/json;charset=utf-8', 'Date': 'Mon, 02 Feb 2026 13:00:04 GMT', 'Link': '<https://codeberg.org/api/v1/repos/gentoo/gentoo/pulls?limit=3&page=2&state=all>; rel="next",<https://codeberg.org/api/v1/repos/gentoo/gentoo/pulls?limit=3&page=9&state=all>; rel="last"', 'Permissions-Policy': 'interest-cohort=()', 'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload', 'Vary': 'Origin', 'Via': '1.1 Caddy', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'X-Total-Count': '26', 'Transfer-Encoding': 'chunked'}
>>> url = https://codeberg.org/api/v1/orgs/bork/teams/?limit=3
{'Access-Control-Expose-Headers': 'X-Total-Count', 'Alt-Svc': 'h3=":443"; ma=2592000,h3=":443"; ma=2592000', 'Cache-Control': 'max-age=0, private, must-revalidate, no-transform', 'Content-Length': '1948', 'Content-Type': 'application/json;charset=utf-8', 'Date': 'Mon, 02 Feb 2026 13:00:22 GMT', 'Permissions-Policy': 'interest-cohort=()', 'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload', 'Vary': 'Origin', 'Via': '1.1 Caddy', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'X-Total-Count': '51'}

I observed this on Codeberg and found what I believe to be the API route implementation here:

ctx.SetTotalCountHeader(count)
ctx.JSON(http.StatusOK, apiTeams)

Compared to another paginated endpoint that I know to work on Codeberg:

ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
ctx.SetTotalCountHeader(maxResults)
ctx.JSON(http.StatusOK, &apiPrs)

Gitea Version

What's deployed on codeberg.org

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

This has been observed on Codeberg.

Database

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions