Skip to content

Commit

Permalink
Ensure matcher values are present when parsing matchers from strings
Browse files Browse the repository at this point in the history
Fixes #2936

Signed-off-by: gotjosh <josue.abreu@gmail.com>
  • Loading branch information
gotjosh committed Jun 28, 2022
1 parent 3f3e2ce commit 895b1b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/labels/parse.go
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pkg/labels/parse_test.go
Expand Up @@ -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`,
Expand Down

0 comments on commit 895b1b0

Please sign in to comment.