Skip to content

PR commits API returns with internal server error if the base branch is missing #36366

@mecseid

Description

@mecseid

Description

Wanted to fetch PR commits from /repos/{owner}/{repo}/pulls/{index}/commits, but if the base (target) branch missing, it returns with HTTP 500.

The corresponding log:

2026/01/14 14:48:17 routers/api/v1/repo/pull.go:1469:GetPullRequestCommits() [E] InternalServerError: exit status 128: Stderr: fatal: bad revision 'release-1.3.0...refs/pull/1/head'
2026/01/14 14:48:17 HTTPRequest [I] router: completed GET /api/v1/repos/TestGroup/test-repo/pulls/1/commits?page=1&limit=100&verification=false&files=false for 10.42.3.51:38594, 500 Internal Server Error in 73.3ms @ repo/pull.go:1395(repo.GetPullRequestCommits)

The UI shows the PR related commits as expected.

Gitea Version

1.24.7

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?

Running inside Kubernetes as a very basic deployment.
Used image is gitea/gitea:1.24.7-rootless

Database

PostgreSQL

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