fix(api): return 409 message instead of empty JSON for wrong commit id (#37572) (#37584)

Backport #37572 by @Exgene

## Issue
Closes #37217 

The error string was getting lost while returning due to `ctx.JSON()`
which cannot serialize the `error` object.

## Fix

Use `ctx.APIError()` to return proper error messages back to the client.

Co-authored-by: Kausthubh J Rao <105716675+Exgene@users.noreply.github.com>
This commit is contained in:
Giteabot
2026-05-07 02:36:52 -07:00
committed by GitHub
parent b586d80f97
commit 2bafa41554
+1 -1
View File
@@ -994,7 +994,7 @@ func MergePullRequest(ctx *context.APIContext) {
return return
} }
if strings.Contains(err.Error(), "Wrong commit ID") { if strings.Contains(err.Error(), "Wrong commit ID") {
ctx.JSON(http.StatusConflict, err) ctx.APIError(http.StatusConflict, err)
return return
} }
ctx.APIErrorInternal(err) ctx.APIErrorInternal(err)