diff --git a/api.go b/api.go index 458164f6e..b954d9268 100644 --- a/api.go +++ b/api.go @@ -1760,6 +1760,9 @@ func (api *API) ImportValueWithTx(ctx context.Context, qcx *Qcx, req *ImportValu // if we're importing into a specific shard if req.Shard != math.MaxUint64 { + if len(req.ColumnIDs) == 0 { + return errors.Wrap(err, "calculating shard, no columns in request") + } // Check that column IDs match the stated shard. shard := req.ColumnIDs[0] / ShardWidth if s2 := req.ColumnIDs[len(req.ColumnIDs)-1] / ShardWidth; (shard != s2) || (shard != req.Shard) { @@ -1798,7 +1801,9 @@ func (api *API) ImportValueWithTx(ctx context.Context, qcx *Qcx, req *ImportValu return errors.Wrap(err, "importing value") } // end if req.Shard != math.MaxUint64 - + if len(req.ColumnIDs) == 0 { + return errors.Wrap(err, "calculating shard, no columns in request") + } options.IgnoreKeyCheck = true start := 0 shard := req.ColumnIDs[0] / ShardWidth diff --git a/http/handler.go b/http/handler.go index 59a3c3162..92f374e84 100644 --- a/http/handler.go +++ b/http/handler.go @@ -2721,6 +2721,10 @@ func (h *Handler) handlePostImport(w http.ResponseWriter, r *http.Request) { qcx := h.api.Txf().NewQcx() defer qcx.Abort() + if len(req.Values) == 0 { + return + } + if err := h.api.ImportValue(r.Context(), qcx, req, opts...); err != nil { switch errors.Cause(err) { case pilosa.ErrClusterDoesNotOwnShard, pilosa.ErrPreconditionFailed: