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) (#17700)

* Return 400 but not 500 when request archive with wrong format (#17691)
* Remove bundle because it's not in this version
This commit is contained in:
Lunny Xiao
2021-11-20 00:31:29 +08:00
committed by GitHub
parent 7be2d7b136
commit a08856606e
4 changed files with 72 additions and 9 deletions

View File

@@ -371,7 +371,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 {