From 19f01691d525f92642c184b9b4921857729a6034 Mon Sep 17 00:00:00 2001 From: Kausthubh J Rao <105716675+Exgene@users.noreply.github.com> Date: Thu, 7 May 2026 07:33:08 +0530 Subject: [PATCH] fix(api): return 409 message instead of empty JSON for wrong commit id (#37572) ## 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. --- routers/api/v1/repo/pull.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 2426a6b3c2..2702f6864f 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -996,7 +996,7 @@ func MergePullRequest(ctx *context.APIContext) { return } if strings.Contains(err.Error(), "Wrong commit ID") { - ctx.JSON(http.StatusConflict, err) + ctx.APIError(http.StatusConflict, err) return } ctx.APIErrorInternal(err)