Return 400 but not 500 when request archive with wrong format (#17691)

This commit is contained in:
Lunny Xiao 2021-11-18 03:47:35 +08:00 committed by GitHub
parent d8a8961b99
commit 81a4fc7528
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 80 additions and 9 deletions

View file

@ -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 {