-
Notifications
You must be signed in to change notification settings - Fork 601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InMemoryChannel receiver validates received events #6511
Conversation
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Codecov Report
@@ Coverage Diff @@
## main #6511 +/- ##
==========================================
- Coverage 82.09% 81.98% -0.12%
==========================================
Files 235 235
Lines 11714 11733 +19
==========================================
+ Hits 9617 9619 +2
- Misses 1628 1642 +14
- Partials 469 472 +3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
bufferedMessage, err := buffering.CopyMessage(request.Context(), message) | ||
if err != nil { | ||
r.logger.Warn("Cannot buffer cloudevent message", zap.Error(err)) | ||
response.WriteHeader(nethttp.StatusBadRequest) | ||
_ = r.reporter.ReportEventCount(&args, nethttp.StatusBadRequest) | ||
return | ||
} | ||
|
||
event, err := binding.ToEvent(request.Context(), bufferedMessage) | ||
if err != nil { | ||
r.logger.Warn("failed to extract event from request", zap.Error(err)) | ||
response.WriteHeader(nethttp.StatusBadRequest) | ||
_ = r.reporter.ReportEventCount(&args, nethttp.StatusBadRequest) | ||
return | ||
} | ||
|
||
// run validation for the extracted event | ||
if err := event.Validate(); err != nil { | ||
r.logger.Warn("failed to validate extracted event", zap.Error(err)) | ||
response.WriteHeader(nethttp.StatusBadRequest) | ||
return | ||
} |
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 move this section into a more encapsulated function?
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.
what should that function return/do?
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.
The binding, validation?
It's ok to inline and grow the functions, but I sometimes feel our funcs get longer and longer.
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.
We can do in a separate PR, if we want to (of course not a blocker) 😅
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: matzew, pierDipi 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 |
/cherry-pick release-1.7 |
@matzew: once the present PR merges, I will cherry-pick it on top of release-1.7 in a new PR and assign it to you. In response to this:
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/test-infra repository. |
/cherry-pick release-1.6 |
@matzew: once the present PR merges, I will cherry-pick it on top of release-1.6 in a new PR and assign it to you. In response to this:
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/test-infra repository. |
/cherry-pick release-1.5 |
@matzew: once the present PR merges, I will cherry-pick it on top of release-1.5 in a new PR and assign it to you. In response to this:
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/test-infra repository. |
/cherry-pick release-1.4 |
@matzew: once the present PR merges, I will cherry-pick it on top of release-1.4 in a new PR and assign it to you. In response to this:
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/test-infra repository. |
@matzew: new pull request created: #6512 In response to this:
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/test-infra repository. |
@matzew: new pull request created: #6513 In response to this:
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/test-infra repository. |
@matzew: new pull request created: #6514 In response to this:
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/test-infra repository. |
@matzew: new pull request created: #6515 In response to this:
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/test-infra repository. |
IMC didn't run validation of the received events.
Signed-off-by: Pierangelo Di Pilato pierdipi@redhat.com
Proposed Changes
Pre-review Checklist
Release Note
Docs