From e664c16b31c86702ac700e04e46ca0890410a6b8 Mon Sep 17 00:00:00 2001 From: Raphael Philipe Mendes da Silva Date: Sun, 24 Nov 2024 08:28:21 -0800 Subject: [PATCH] api: fix typo in list rules API response (#15400) * Fix typo in list rules API response --------- Signed-off-by: Raphael Silva --- web/api/v1/api.go | 2 +- web/api/v1/api_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/web/api/v1/api.go b/web/api/v1/api.go index 85d48f28f..38a6e6781 100644 --- a/web/api/v1/api.go +++ b/web/api/v1/api.go @@ -1374,7 +1374,7 @@ func (api *API) metricMetadata(r *http.Request) apiFuncResult { // RuleDiscovery has info for all rules. type RuleDiscovery struct { RuleGroups []*RuleGroup `json:"groups"` - GroupNextToken string `json:"groupNextToken:omitempty"` + GroupNextToken string `json:"groupNextToken,omitempty"` } // RuleGroup has info for rules which are part of a group. diff --git a/web/api/v1/api_test.go b/web/api/v1/api_test.go index ad2434ee6..14fcfea04 100644 --- a/web/api/v1/api_test.go +++ b/web/api/v1/api_test.go @@ -2899,6 +2899,14 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E errType: errorBadData, zeroFunc: rulesZeroFunc, }, + { // groupNextToken should not be in empty response + endpoint: api.rules, + query: url.Values{ + "match[]": []string{`{testlabel="abc-cannot-find"}`}, + "group_limit": []string{"1"}, + }, + responseAsJSON: `{"groups":[]}`, + }, { endpoint: api.queryExemplars, query: url.Values{