From 81a4fc752833101dd7d6b4f612bccc4b29c98dff Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 18 Nov 2021 03:47:35 +0800 Subject: Return 400 but not 500 when request archive with wrong format (#17691) --- routers/web/repo/repo.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'routers') diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index 46cef7664a..5e15415d6a 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -373,7 +373,11 @@ func Download(ctx *context.Context) { uri := ctx.Params("*") aReq, err := archiver_service.NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, uri) if err != nil { - ctx.ServerError("archiver_service.NewRequest", err) + if errors.Is(err, archiver_service.ErrUnknownArchiveFormat{}) { + ctx.Error(http.StatusBadRequest, err.Error()) + } else { + ctx.ServerError("archiver_service.NewRequest", err) + } return } if aReq == nil { -- cgit v1.2.3