Skip to content

Commit a245255

Browse files
committed
Fix: Add NotStartsWith to negative condition checks
The NotStartsWith filter was being treated as a positive condition, causing incorrect filter logic. Stack filters with negative conditions need ALL functions to not match (AND logic), while positive conditions need ANY function to match (OR logic). Fixed in 4 functions: - handleUnsymbolizedFunctionCondition - matchesFunctionNameInRange - matchesSystemNameInRange - matchesFilenameInRange This fixes the failing TestStackFilterFunctionNameNotStartsWith test.
1 parent 40c2f90 commit a245255

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

pkg/query/columnquery.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -715,22 +715,22 @@ func stackMatchesFilter(
715715

716716
func handleUnsymbolizedFunctionCondition(fnCond *pb.StringCondition) bool {
717717
switch fnCond.GetCondition().(type) {
718-
case *pb.StringCondition_Contains, *pb.StringCondition_Equal:
719-
// For Contains/Equal: no function names means no matches
718+
case *pb.StringCondition_Contains, *pb.StringCondition_Equal, *pb.StringCondition_StartsWith:
719+
// For Contains/Equal/StartsWith: no function names means no matches
720720
return false
721-
case *pb.StringCondition_NotContains, *pb.StringCondition_NotEqual:
722-
// For NotContains/NotEqual: no function names means condition is satisfied
721+
case *pb.StringCondition_NotContains, *pb.StringCondition_NotEqual, *pb.StringCondition_NotStartsWith:
722+
// For NotContains/NotEqual/NotStartsWith: no function names means condition is satisfied
723723
return true
724724
}
725725
return false
726726
}
727727

728728
func matchesFunctionNameInRange(r *profile.RecordReader, firstStart, lastEnd int, fnCond *pb.StringCondition) bool {
729-
// For NotContains/NotEqual, we need ALL functions to not contain/equal the target (AND logic)
730-
// For Contains/Equal, we need ANY function to contain/equal the target (OR logic)
729+
// For NotContains/NotEqual/NotStartsWith, we need ALL functions to not contain/equal/start-with the target (AND logic)
730+
// For Contains/Equal/StartsWith, we need ANY function to contain/equal/start-with the target (OR logic)
731731
isNegativeCondition := false
732732
switch fnCond.GetCondition().(type) {
733-
case *pb.StringCondition_NotContains, *pb.StringCondition_NotEqual:
733+
case *pb.StringCondition_NotContains, *pb.StringCondition_NotEqual, *pb.StringCondition_NotStartsWith:
734734
isNegativeCondition = true
735735
}
736736

@@ -771,7 +771,7 @@ func matchesFunctionNameInRange(r *profile.RecordReader, firstStart, lastEnd int
771771
func matchesSystemNameInRange(r *profile.RecordReader, firstStart, lastEnd int, sysCond *pb.StringCondition) bool {
772772
isNegativeCondition := false
773773
switch sysCond.GetCondition().(type) {
774-
case *pb.StringCondition_NotContains, *pb.StringCondition_NotEqual:
774+
case *pb.StringCondition_NotContains, *pb.StringCondition_NotEqual, *pb.StringCondition_NotStartsWith:
775775
isNegativeCondition = true
776776
}
777777

@@ -802,7 +802,7 @@ func matchesSystemNameInRange(r *profile.RecordReader, firstStart, lastEnd int,
802802
func matchesFilenameInRange(r *profile.RecordReader, firstStart, lastEnd int, fileCond *pb.StringCondition) bool {
803803
isNegativeCondition := false
804804
switch fileCond.GetCondition().(type) {
805-
case *pb.StringCondition_NotContains, *pb.StringCondition_NotEqual:
805+
case *pb.StringCondition_NotContains, *pb.StringCondition_NotEqual, *pb.StringCondition_NotStartsWith:
806806
isNegativeCondition = true
807807
}
808808

0 commit comments

Comments
 (0)