Skip to content

Commit

Permalink
fix: return false on uncomparable filter instead of panic
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Davis <[email protected]>
  • Loading branch information
Jeff Davis committed Jun 15, 2021
1 parent 637b8b6 commit ed4ed3e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/yamlpath/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit ed4ed3e

Please sign in to comment.