From d936ea8ab0602b135662db698860f19b96898e7b Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 6 Aug 2018 11:11:01 +0530 Subject: [PATCH] return 400 if request validation fails Signed-off-by: Madhu Rajanna --- glusterd2/commands/snapshot/snapshot-activate.go | 2 +- glusterd2/commands/snapshot/snapshot-clone.go | 4 ++-- glusterd2/commands/snapshot/snapshot-create.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/glusterd2/commands/snapshot/snapshot-activate.go b/glusterd2/commands/snapshot/snapshot-activate.go index 5f3d2d895..532f0c55e 100644 --- a/glusterd2/commands/snapshot/snapshot-activate.go +++ b/glusterd2/commands/snapshot/snapshot-activate.go @@ -167,7 +167,7 @@ func snapshotActivateHandler(w http.ResponseWriter, r *http.Request) { var req api.SnapActivateReq vol = &snapinfo.SnapVolinfo if err := restutils.UnmarshalRequest(r, &req); err != nil { - restutils.SendHTTPError(ctx, w, http.StatusUnprocessableEntity, err) + restutils.SendHTTPError(ctx, w, http.StatusBadRequest, err) return } diff --git a/glusterd2/commands/snapshot/snapshot-clone.go b/glusterd2/commands/snapshot/snapshot-clone.go index c4b84235d..a3fc775ca 100644 --- a/glusterd2/commands/snapshot/snapshot-clone.go +++ b/glusterd2/commands/snapshot/snapshot-clone.go @@ -286,7 +286,7 @@ func snapshotCloneHandler(w http.ResponseWriter, r *http.Request) { snapname := mux.Vars(r)["snapname"] if snapname == "" { - restutils.SendHTTPError(ctx, w, http.StatusUnprocessableEntity, errors.New("Snapshot name should not be empty")) + restutils.SendHTTPError(ctx, w, http.StatusBadRequest, errors.New("Snapshot name should not be empty")) return } @@ -296,7 +296,7 @@ func snapshotCloneHandler(w http.ResponseWriter, r *http.Request) { } if !volume.IsValidName(req.CloneName) { - restutils.SendHTTPError(ctx, w, http.StatusUnprocessableEntity, gderrors.ErrInvalidVolName) + restutils.SendHTTPError(ctx, w, http.StatusBadRequest, gderrors.ErrInvalidVolName) return } diff --git a/glusterd2/commands/snapshot/snapshot-create.go b/glusterd2/commands/snapshot/snapshot-create.go index 3f994b1df..6ee20c5b8 100644 --- a/glusterd2/commands/snapshot/snapshot-create.go +++ b/glusterd2/commands/snapshot/snapshot-create.go @@ -705,7 +705,7 @@ func snapshotCreateHandler(w http.ResponseWriter, r *http.Request) { } if !volume.IsValidName(req.SnapName) { - restutils.SendHTTPError(ctx, w, http.StatusUnprocessableEntity, gderrors.ErrInvalidSnapName) + restutils.SendHTTPError(ctx, w, http.StatusBadRequest, gderrors.ErrInvalidSnapName) return }