diff --git a/pkg/labels/parse.go b/pkg/labels/parse.go index d0978ff6..06a414e7 100644 --- a/pkg/labels/parse.go +++ b/pkg/labels/parse.go @@ -120,18 +120,14 @@ func ParseMatcher(s string) (_ *Matcher, err error) { return nil, errors.Errorf("bad matcher format: %s", s) } - rawValue := ms[3] - if len(rawValue) == 0 { - return nil, errors.Errorf("matcher value is not present: %s", s) - } - var ( + rawValue = ms[3] value strings.Builder escaped bool expectTrailingQuote bool ) - if rawValue[0] == '"' { + if strings.HasPrefix(rawValue, "\"") { rawValue = strings.TrimPrefix(rawValue, "\"") expectTrailingQuote = true } diff --git a/pkg/labels/parse_test.go b/pkg/labels/parse_test.go index b1f53ef2..e1203f4a 100644 --- a/pkg/labels/parse_test.go +++ b/pkg/labels/parse_test.go @@ -191,7 +191,10 @@ func TestMatchers(t *testing.T) { }, { input: `job=`, - err: `matcher value is not present: job=`, + want: func() []*Matcher { + m, _ := NewMatcher(MatchEqual, "job", "") + return []*Matcher{m} + }(), }, { input: `job="value`,