-
Notifications
You must be signed in to change notification settings - Fork 43
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
Events of type "repository" now avoid checking hook id. #3463
Conversation
Events of type "repository" having "action" delete must trigger the deletion of registered repositories. Given we use the same deserialization struct for both "repository" and "meta" events, we erroneously checked the received hook id against the one stored in the database, thus consistently failing. Added fix, test case, and improved logs.
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.
Oops, one more comment
@@ -678,7 +694,7 @@ func (s *Server) processRelevantRepositoryEvent( | |||
} | |||
|
|||
// This only makes sense for "meta" event type | |||
if dbrepo.WebhookID.Valid { | |||
if event.GetHookID() != 0 && dbrepo.WebhookID.Valid { | |||
// Check if the payload webhook ID matches the one we | |||
// have stored in the DB for this repository | |||
if event.GetHookID() != dbrepo.WebhookID.Int64 { |
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.
Does the comment on line 701-703 still make sense?
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.
I think it does.
This routine is called only on meta
and repository
events, and this fix ensures that we check the hook id only when available, which is the case solely for the meta
event.
The comment per sé is still valid, but can be removed if it's not useful.
I lean towards leaving it there for posterity, maybe rewriting it at the top of the if
, but let me know.
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.
I agree that it's valid and useful
Summary
Events of type "repository" having "action" delete must trigger the deletion of registered repositories. Given we use the same deserialization struct for both "repository" and "meta" events, we erroneously checked the received hook id against the one stored in the database, thus consistently failing.
Added fix, test case, and improved logs.
Fixes #3461
Change Type
Mark the type of change your PR introduces:
Testing
Review Checklist: