From ea05d182bdbf797ab0040a0e931fe84d25668213 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 7 Jun 2020 19:30:58 +0200 Subject: [PATCH 1/2] In File Create/Update API return 404 if Branch does not exist (#11791) --- routers/api/v1/repo/file.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index 73b8e31a44217..a43fdb074e2e9 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -350,6 +350,10 @@ func handleCreateOrUpdateFileError(ctx *context.APIContext, err error) { ctx.Error(http.StatusUnprocessableEntity, "Invalid", err) return } + if models.IsErrBranchDoesNotExist(err) || git.IsErrBranchNotExist(err) { + ctx.Error(http.StatusNotFound, "BranchDoesNotExist", err) + return + } ctx.Error(http.StatusInternalServerError, "UpdateFile", err) } From 2a29db70b72aeca8e3c8b9bc8b2da592343c9deb Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 7 Jun 2020 21:01:42 +0200 Subject: [PATCH 2/2] v1.12 version ;) --- routers/api/v1/repo/file.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index a43fdb074e2e9..9754bb7966bc4 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -350,7 +350,7 @@ func handleCreateOrUpdateFileError(ctx *context.APIContext, err error) { ctx.Error(http.StatusUnprocessableEntity, "Invalid", err) return } - if models.IsErrBranchDoesNotExist(err) || git.IsErrBranchNotExist(err) { + if git.IsErrBranchNotExist(err) { ctx.Error(http.StatusNotFound, "BranchDoesNotExist", err) return }