Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix(eventfilter): guard notFilter.Cleanup against a nil nested filter - #9521

Open
arpitjain099 wants to merge 1 commit into
knative:mainfrom
arpitjain099:fix/notfilter-cleanup-nil-guard
Open

arpitjain099 wants to merge 1 commit into
knative:mainfrom
arpitjain099:fix/notfilter-cleanup-nil-guard

Conversation

@arpitjain099

Copy link
Copy Markdown

A Trigger with not: {} passes the webhook, since ValidateOneOf only rejects filters that set more than one dialect. MaterializeSubscriptionsAPIFilter returns nil for the empty nested filter, so NewNotFilter wraps nil. MaterializeFiltersList keeps 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, and FiltersMap.Set calls Cleanup on the one it replaces, so the next update to that Trigger dereferences nil in the filter pod. Delete does 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

  • 🐛 Make notFilter.Cleanup return early on a nil nested filter, the same check Filter() already makes

Pre-review Checklist

  • At least 80% unit test coverage
  • E2E tests for any new behavior
  • Docs PR for any user-facing impact
  • Spec PR for any new API feature
  • Conformance test for any change to the spec

Testing

TestFiltersMapTriggerWithEmptyNotFilter builds the filter from a Trigger spec through CreateSubscriptionsAPIFilters, then calls Set twice the way the informer's UpdateFunc does, followed by Delete. On main it panics at not_filter.go:52 through filters_map.go:42; with the change it passes. go test -race ./pkg/eventfilter/... goes from 115 to 116, and go test ./pkg/... is green.

Release Note

A Trigger with an empty `not` filter no longer causes a nil dereference in the broker filter when that Trigger is updated or deleted.

This change was written with the assistance of generative AI. I have reviewed and tested every line of it.

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>
@knative-prow knative-prow Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 12, 2026
@knative-prow

knative-prow Bot commented Nov 12, 2026

Copy link
Copy Markdown

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

@knative-prow
knative-prow Bot requested review from Leo6Leo and aliok November 12, 2026 19:10
@knative-prow

knative-prow Bot commented Nov 12, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: arpitjain099
Once this PR has been reviewed and has the lgtm label, please assign creydr for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant