Skip to content

Commit d997eed

Browse files
fix: support UTF-8 label names for label values API (#8499)
Related to #6931 Signed-off-by: Simon Pasquier <[email protected]>
1 parent 58f15ea commit d997eed

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
1414

1515
- [#8334](https://github.com/thanos-io/thanos/pull/8334) Query: wait for initial endpoint discovery before becoming ready
1616
- [#8486](https://github.com/thanos-io/thanos/pull/8486) Receive: fix exemplar label corruption from Cap'n Proto memory references
17+
- [#8499](https://github.com/thanos-io/thanos/pull/8499) Query: support UTF-8 label names for the `/api/v1/label/:name/values` API.
1718

1819
### Added
1920

pkg/api/query/v1.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,8 @@ func (qapi *QueryAPI) labelValues(r *http.Request) (any, []error, *api.ApiError,
10251025
ctx := r.Context()
10261026
name := route.Param(ctx, "name")
10271027

1028-
if !model.LabelNameRE.MatchString(name) {
1028+
label := model.LabelName(name)
1029+
if !label.IsValid() {
10291030
return nil, nil, &api.ApiError{Typ: api.ErrorBadData, Err: errors.Errorf("invalid label name: %q", name)}, func() {}
10301031
}
10311032

pkg/api/query/v1_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -955,13 +955,13 @@ func TestMetadataEndpoints(t *testing.T) {
955955
},
956956
response: []string{"a"},
957957
},
958-
// Bad name parameter.
958+
// UTF-8 label name.
959959
{
960960
endpoint: api.labelValues,
961961
params: map[string]string{
962-
"name": "not!!!allowed",
962+
"name": "http.request.method",
963963
},
964-
errType: baseAPI.ErrorBadData,
964+
response: []string{},
965965
},
966966
{
967967
endpoint: api.series,

0 commit comments

Comments
 (0)