From 2bafa4155413e2c7380b935b0657b09af31ab44b Mon Sep 17 00:00:00 2001 From: Giteabot Date: Thu, 7 May 2026 02:36:52 -0700 Subject: [PATCH] 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> --- 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 ef8cc6cd93..c435df4b1f 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -994,7 +994,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)