Repository navigation
fix(eventfilter): guard notFilter.Cleanup against a nil nested filter - #9521
arpitjain099 wants to merge 1 commit into
Conversation
A SubscriptionsAPIFilter with no dialect set materializes to nil, so a
Trigger with `not: {}` becomes a notFilter wrapping nothing. Filter()
already checks for that; Cleanup() did not, and FiltersMap.Set and
Delete both call Cleanup on the filter they replace or remove.
This adds the same check Filter() makes.
This change was written with the assistance of generative AI. I have
reviewed and tested every line of it.
Signed-off-by: arpitjain099 <arpitjain099@gmail.com>
|
Hi @arpitjain099. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: arpitjain099 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
A Trigger with
not: {}passes the webhook, sinceValidateOneOfonly rejects filters that set more than one dialect.MaterializeSubscriptionsAPIFilterreturns nil for the empty nested filter, soNewNotFilterwraps nil.MaterializeFiltersListkeeps it, since the interface value is not nil.Filter()guards the receiver and the nested filter.Cleanup()does not. The broker filter's informer stores a filter per Trigger, andFiltersMap.SetcallsCleanupon the one it replaces, so the next update to that Trigger dereferences nil in the filter pod.Deletedoes the same on removal.Rejecting a dialect-less filter would be the fuller fix, but it turns away objects accepted today, so I left it out.
Proposed Changes
notFilter.Cleanupreturn early on a nil nested filter, the same checkFilter()already makesPre-review Checklist
Testing
TestFiltersMapTriggerWithEmptyNotFilterbuilds the filter from a Trigger spec throughCreateSubscriptionsAPIFilters, then callsSettwice the way the informer'sUpdateFuncdoes, followed byDelete. On main it panics atnot_filter.go:52throughfilters_map.go:42; with the change it passes.go test -race ./pkg/eventfilter/...goes from 115 to 116, andgo test ./pkg/...is green.Release Note
This change was written with the assistance of generative AI. I have reviewed and tested every line of it.