Skip to content

fix(api): handle missing base branch in PR commits API (#37193)#37203

Merged
silverwind merged 2 commits into
go-gitea:release/v1.26from
GiteaBot:backport-37193-v1.26
Apr 13, 2026
Merged

fix(api): handle missing base branch in PR commits API (#37193)#37203
silverwind merged 2 commits into
go-gitea:release/v1.26from
GiteaBot:backport-37193-v1.26

Conversation

@GiteaBot
Copy link
Copy Markdown
Collaborator

Backport #37193 by @Mohit25022005

fix(api): handle missing base branch in PR commits API

Closes #36366

Previously, the PR commits API returned a 500 Internal Server Error
when the base branch was missing due to an unhandled git "bad revision" error.

This change:

  • Checks for base branch existence before performing git operations
  • Returns 404 when the base branch does not exist
  • Prevents git errors from surfacing as 500 responses

This improves API robustness and aligns behavior with expected error handling.

Tested locally by:

  • Creating a pull request
  • Deleting the base branch
  • Verifying that the API returns 404 instead of 500

Closes go-gitea#36366

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@GiteaBot GiteaBot requested review from bircni and wxiaoguang April 13, 2026 20:01
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 13, 2026
@GiteaBot GiteaBot added this to the 1.26.0 milestone Apr 13, 2026
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 13, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 13, 2026
@silverwind silverwind merged commit 68f5e40 into go-gitea:release/v1.26 Apr 13, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants