Skip to content

Commit 471246d

Browse files
chore: Fix panic for queries with unsupported predicate types (backport k270) (#19087)
Co-authored-by: benclive <[email protected]>
1 parent 49afe78 commit 471246d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pkg/dataobj/metastore/object.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@ func pointerPredicateFromMatchers(matchers ...*labels.Matcher) pointers.RowPredi
416416
}
417417
}
418418

419+
if len(predicates) == 0 {
420+
return nil
421+
}
422+
419423
current := predicates[0]
420424

421425
for _, predicate := range predicates[1:] {

pkg/dataobj/metastore/object_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,16 @@ func TestSectionsForStreamMatchers(t *testing.T) {
335335
predicates: nil,
336336
wantCount: 0,
337337
},
338+
{
339+
name: "matching selector with unsupported predicate type",
340+
matchers: []*labels.Matcher{
341+
labels.MustNewMatcher(labels.MatchEqual, "app", "foo"),
342+
},
343+
predicates: []*labels.Matcher{
344+
labels.MustNewMatcher(labels.MatchRegexp, "bar", "something"),
345+
},
346+
wantCount: 1,
347+
},
338348
}
339349

340350
for _, tt := range tests {

0 commit comments

Comments
 (0)