Skip to content

Commit

Permalink
Merge pull request #2968 from prometheus/parse-matchers-empty-value
Browse files Browse the repository at this point in the history
Ensure matcher values are present when parsing matchers from strings
  • Loading branch information
gotjosh committed Sep 30, 2022
2 parents 0a9a48d + bd89550 commit 5455296
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/labels/parse.go
Expand Up @@ -127,7 +127,7 @@ func ParseMatcher(s string) (_ *Matcher, err error) {
expectTrailingQuote bool
)

if rawValue[0] == '"' {
if strings.HasPrefix(rawValue, "\"") {
rawValue = strings.TrimPrefix(rawValue, "\"")
expectTrailingQuote = true
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/labels/parse_test.go
Expand Up @@ -189,6 +189,13 @@ func TestMatchers(t *testing.T) {
return append(ms, m, m2)
}(),
},
{
input: `job=`,
want: func() []*Matcher {
m, _ := NewMatcher(MatchEqual, "job", "")
return []*Matcher{m}
}(),
},
{
input: `job="value`,
err: `matcher value contains unescaped double quote: "value`,
Expand Down

0 comments on commit 5455296

Please sign in to comment.