fix: return bad request on malformed packages upload input (#10954)

I noticed that the wrong content type in an `/upload` request can trigger a 500, and I'm guessing it is more appropriate to return 400 instead.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10954
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Roberto Vidal <roberto.vidal@ikumene.com>
Co-committed-by: Roberto Vidal <roberto.vidal@ikumene.com>
This commit is contained in:
Roberto Vidal
2026-02-13 18:04:19 +01:00
committed by Gusted
parent cd088f21a8
commit ef7acda8be
29 changed files with 153 additions and 14 deletions
+4
View File
@@ -30,3 +30,7 @@ func (ctx *Context) UploadStream() (rd io.ReadCloser, needToClose bool, err erro
}
return ctx.Req.Body, false, nil
}
func IsFormError(err error) bool {
return err == http.ErrMissingFile || err == http.ErrMissingBoundary
}