From ed4ed3ea1bff7f8d197732f752889ea2c3014e61 Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Tue, 15 Jun 2021 13:34:19 -0500 Subject: [PATCH] fix: return false on uncomparable filter instead of panic Signed-off-by: Jeff Davis --- pkg/yamlpath/filter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/yamlpath/filter.go b/pkg/yamlpath/filter.go index f35a8d9..dead191 100644 --- a/pkg/yamlpath/filter.go +++ b/pkg/yamlpath/filter.go @@ -290,7 +290,7 @@ func matchRegularExpression(parseTree *filterNode) filter { func stringMatchesRegularExpression(s, expr typedValue) bool { if s.typ != stringValueType || expr.typ != regularExpressionValueType { - panic("unexpected types") // should never happen + return false // can't compare types so return false } re, _ := regexp.Compile(expr.val) // regex already compiled during lexing return re.Match([]byte(s.val))