diff --git a/handler.go b/handler.go index ffd28da46..02d20564c 100644 --- a/handler.go +++ b/handler.go @@ -122,7 +122,7 @@ func BuildRouters(handler *Handler) { func (h *Handler) populateValidators() { h.validators = map[string]*queryValidationSpec{} - h.validators["GetFragmentNodes"] = QueryValidationSpecRequired("slice").Optional("index") + h.validators["GetFragmentNodes"] = QueryValidationSpecRequired("slice", "index") h.validators["GetSliceMax"] = QueryValidationSpecRequired().Optional("inverse") h.validators["PostQuery"] = QueryValidationSpecRequired().Optional("slices", "columnAttrs", "excludeAttrs", "excludeBits") h.validators["GetExport"] = QueryValidationSpecRequired("index", "frame", "view", "slice") diff --git a/handler_test.go b/handler_test.go index ba9480544..12c145e87 100644 --- a/handler_test.go +++ b/handler_test.go @@ -1225,6 +1225,13 @@ func TestHandler_Fragment_Nodes(t *testing.T) { t.Fatalf("unexpected status code: %d", w.Code) } + // index is required + w = httptest.NewRecorder() + r = test.MustNewHTTPRequest("GET", "/fragment/nodes?slice=0", nil) + h.ServeHTTP(w, r) + if w.Code != http.StatusBadRequest { + t.Fatalf("unexpected status code: %d", w.Code) + } } // Ensure the handler can return expvars without panicking.