Skip to content

Commit 1d24632

Browse files
add logical check before creating result: #4603 (#4608)
1 parent 3978d5d commit 1d24632

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/protocols/protocols.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,19 @@ type Request interface {
215215
type OutputEventCallback func(result *output.InternalWrappedEvent)
216216

217217
func MakeDefaultResultEvent(request Request, wrapped *output.InternalWrappedEvent) []*output.ResultEvent {
218+
// Note: operator result is generated if something was succesfull match/extract/dynamic-extract
219+
// but results should not be generated if
220+
// 1. no match was found and some dynamic values were extracted
221+
// 2. if something was extracted (matchers exist but no match was found)
218222
if len(wrapped.OperatorsResult.DynamicValues) > 0 && !wrapped.OperatorsResult.Matched {
219223
return nil
220224
}
225+
// check if something was extracted (except dynamic values)
226+
extracted := len(wrapped.OperatorsResult.Extracts) > 0 || len(wrapped.OperatorsResult.OutputExtracts) > 0
227+
if extracted && len(wrapped.OperatorsResult.Operators.Matchers) > 0 && !wrapped.OperatorsResult.Matched {
228+
// if extracted and matchers exist but no match was found then don't generate result
229+
return nil
230+
}
221231

222232
results := make([]*output.ResultEvent, 0, len(wrapped.OperatorsResult.Matches)+1)
223233

0 commit comments

Comments
 (0)