diff --git a/pkg/labels/parse.go b/pkg/labels/parse.go index 0a242d50..d0978ff6 100644 --- a/pkg/labels/parse.go +++ b/pkg/labels/parse.go @@ -120,8 +120,12 @@ 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 diff --git a/pkg/labels/parse_test.go b/pkg/labels/parse_test.go index c15541b8..b1f53ef2 100644 --- a/pkg/labels/parse_test.go +++ b/pkg/labels/parse_test.go @@ -189,6 +189,10 @@ func TestMatchers(t *testing.T) { return append(ms, m, m2) }(), }, + { + input: `job=`, + err: `matcher value is not present: job=`, + }, { input: `job="value`, err: `matcher value contains unescaped double quote: "value`,