From 5206e8fa0e0c8ab8a3c714a59340857551fa852b Mon Sep 17 00:00:00 2001 From: Samir Patel <48686912+54mir@users.noreply.github.com> Date: Mon, 1 Nov 2021 18:19:38 -0500 Subject: [PATCH] more comprehensive value check --- http/handler.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/http/handler.go b/http/handler.go index 59a3c3162..9b65fe257 100644 --- a/http/handler.go +++ b/http/handler.go @@ -2721,6 +2721,9 @@ func (h *Handler) handlePostImport(w http.ResponseWriter, r *http.Request) { qcx := h.api.Txf().NewQcx() defer qcx.Abort() + if isImportRequestEmpty(req) { + return + } if err := h.api.ImportValue(r.Context(), qcx, req, opts...); err != nil { switch errors.Cause(err) { case pilosa.ErrClusterDoesNotOwnShard, pilosa.ErrPreconditionFailed: @@ -3463,3 +3466,8 @@ func (h *Handler) handlePostRestore(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write([]byte("OK")) //nolint:errcheck } + +func isImportRequestEmpty(req *pilosa.ImportValueRequest) bool { + totalData := len(req.Values) + len(req.FloatValues) + len(req.TimestampValues) + len(req.StringValues) + return totalData == 0 +}