1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

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