diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-18 03:47:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-17 14:47:35 -0500 |
commit | 81a4fc752833101dd7d6b4f612bccc4b29c98dff (patch) | |
tree | 3fc851bbdbebf63a3c684791368c33efaf077005 /routers | |
parent | d8a8961b99adc1554c218fee474535d4f302bd11 (diff) | |
download | gitea-81a4fc752833101dd7d6b4f612bccc4b29c98dff.tar.gz gitea-81a4fc752833101dd7d6b4f612bccc4b29c98dff.zip |
Return 400 but not 500 when request archive with wrong format (#17691)
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/repo/repo.go | 6 |
1 files changed, 5 insertions, 1 deletions
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 { |