Skip to content

Commit

Permalink
fix: better error message when the max upload size is exceeded
Browse files Browse the repository at this point in the history
Signed-off-by: Harikrishnan Balagopal <[email protected]>
  • Loading branch information
HarikrishnanBalagopal committed Feb 23, 2024
1 parent 8779288 commit 1ea7d59
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/move2kubeapi/handlers/inputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ func HandleCreateProjectInput(w http.ResponseWriter, r *http.Request, isCommon b
}
r.Body = http.MaxBytesReader(w, r.Body, common.Config.MaxUploadSize)
if err := r.ParseMultipartForm(common.Config.MaxUploadSize); err != nil {
if _, ok := err.(*http.MaxBytesError); ok {

Check failure on line 56 in internal/move2kubeapi/handlers/inputs.go

View workflow job for this annotation

GitHub Actions / Build and test

undefined: http.MaxBytesError
logrus.Errorf("request body exceeded max upload size of '%d' bytes. Error: %q", common.Config.MaxUploadSize, err)
sendErrorJSON(
w,
"Request body exceeded max upload size. Try using a smaller input or contact your Admin to increase the max upload size.",
http.StatusBadRequest,
)
return
}
logrus.Errorf("failed to parse the request body as multipart/form-data. Error: %q", err)
sendErrorJSON(w, "failed to parse the request body as multipart/form-data", http.StatusBadRequest)
return
Expand Down

0 comments on commit 1ea7d59

Please sign in to comment.