-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix nil pointer exception for nil interceptor #1325
Conversation
The following is the coverage report on the affected files.
|
/kind bug |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: khrm The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test pull-tekton-triggers-integration-tests |
@dibyom PTAL |
@@ -286,6 +286,10 @@ func (t *EventListenerTrigger) validate(ctx context.Context) (errs *apis.FieldEr | |||
|
|||
// Validate optional Interceptors | |||
for i, interceptor := range t.Interceptors { | |||
// No continuation if provided interceptor is nil. | |||
if interceptor == nil { | |||
return errs.Also(apis.ErrInvalidValue(fmt.Sprintf("interceptor '%v' must be a valid value", interceptor), fmt.Sprintf("interceptors[%d]", i))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a quick unit test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dibyom added unit test
PTAL
Thanks @savitaashture This looks good - can we just add a unit test to verify the behavior. |
The following is the coverage report on the affected files.
|
438185b
to
3916e1a
Compare
The following is the coverage report on the affected files.
|
/lgtm |
Changes
Issue: While creating EL if user provide
null
in Interceptors webhook pod will crashRoot Cause: Failure is because of accessing nil object
https://github.com/tektoncd/triggers/blob/main/pkg/apis/triggers/v1alpha1/trigger_types.go#L139
Fix: Added validation to check interceptor is nil or not if nill webhook validation through error
More Info: https://tektoncd.slack.com/archives/CKUSJ2A5D/p1647257237334749
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Release Notes