From 5f3a2aafdf51e6af0d8cc50dc02c28718ca25882 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Thu, 5 Sep 2024 20:39:23 +0200 Subject: [PATCH] Return 404 instead of error when commit not exist (#31977) Fix #31976 (cherry picked from commit bf7ae0429cdf236510aa6702e499878bc2345a6e) --- routers/api/v1/repo/commits.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go index 5e7d10e6c2..c5e8cf99eb 100644 --- a/routers/api/v1/repo/commits.go +++ b/routers/api/v1/repo/commits.go @@ -195,7 +195,7 @@ func GetAllCommits(ctx *context.APIContext) { // get commit specified by sha baseCommit, err = ctx.Repo.GitRepo.GetCommit(sha) if err != nil { - ctx.Error(http.StatusInternalServerError, "GetCommit", err) + ctx.NotFoundOrServerError("GetCommit", git.IsErrNotExist, err) return } }