You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Steps to reproduce:
List the minimal actions needed to reproduce the behavior.
Create a set of NotificationRules in which some rules have defined tagRules e.g. tagRules: [{key: 'bird', value: 'jay', operator: 'equal'}] and in which some rules have tagRules: undefined.
Send a GET request to /notificationRules with the query param ?tag=bird:jay
Expected behavior:
Expected the result set in the response to contain only those rules that have the tagRule [{key: 'bird', value: 'jay', operator: 'equal'}]
Actual behavior:
The result set contains rules with the tagRule [{key: 'bird', value: 'jay'}] but also rules that have NO DEFINED TAGRULES property.
partial result set from console log - note first record has no tagRules property.
I'm a newbie to GOLANG so this may not be correct (relying on other C lang family experience), but looking into notification/rule/rule.go I see the following function.
// MatchesTags returns true if the Rule matches all of the tagsfunc (b*Base) MatchesTags(tags []influxdb.Tag) bool {
iflen(tags) ==0 {
returntrue
}
// for each tag in NR// if there exists// a key value match with operator == equal in tags// or// a key match with a value mismatch with operator == notequal in tags// then truefor_, NRtag:=rangeb.TagRules {
isNRTagInFilterTags:=falsefor_, filterTag:=rangetags {
ifNRtag.Key==filterTag.Key {
ifNRtag.Operator==influxdb.Equal&&NRtag.Value==filterTag.Value {
isNRTagInFilterTags=true
}
ifNRtag.Operator==influxdb.NotEqual&&NRtag.Value!=filterTag.Value {
isNRTagInFilterTags=true
}
}
}
if!isNRTagInFilterTags {
returnfalse
}
}
returntrue
}
What happens to the for _, NRtag := range b.TagRules block when b has no TagRules? Isn't the block skipped and the function returns true?
Steps to reproduce:
List the minimal actions needed to reproduce the behavior.
tagRules: [{key: 'bird', value: 'jay', operator: 'equal'}]
and in which some rules havetagRules: undefined
./notificationRules
with the query param?tag=bird:jay
Expected behavior:
Expected the result set in the response to contain only those rules that have the tagRule
[{key: 'bird', value: 'jay', operator: 'equal'}]
Actual behavior:
The result set contains rules with the tagRule
[{key: 'bird', value: 'jay'}]
but also rules that have NO DEFINED TAGRULES property.partial result set from console log - note first record has no tagRules property.
Digging in Code
I'm a newbie to GOLANG so this may not be correct (relying on other C lang family experience), but looking into
notification/rule/rule.go
I see the following function.What happens to the
for _, NRtag := range b.TagRules
block when b has no TagRules? Isn't the block skipped and the function returns true?Environment info:
Testing in K8SIDPE remocal.
latest commit
The text was updated successfully, but these errors were encountered: