-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Integration Re-sync Bug Fix #6124
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
Conversation
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're adding remove_secret
a lot of places in this PR. It feels like it's almost certainly too complex. Why wasn't this needed before, but is needed now?
@ericholscher This is done because previously we did not sync webhooks when we create an integration but now we do so. If for any reason the webhook fails to re-sync this tries to remove the |
Ugh, I broke something trying to push to this branch. Silly github :/ |
67cd06a
to
79cdefb
Compare
Alright, fixed up the commits, and cleaned up some of the logic. I think it makes more sense now -- I'm not 100% sold on the GitHub |
readthedocs/oauth/services/github.py
Outdated
@@ -203,7 +203,7 @@ def setup_webhook(self, project, integration=None): | |||
""" | |||
session = self.get_session() | |||
owner, repo = build_utils.get_github_username_repo(url=project.repo) | |||
if integration: | |||
if integration and not integration.secret: |
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.
@ericholscher When we pass the integration from update_webhook
to setup_webhook
on 404
the integration already has a secret so this condition always returns False
and creates a new integration. thats why some tests are failing.
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.
This is a much better approach. It will allow us to "reclaim" a webhook on GitHub if it already exists, and update it if it doesn't.
readthedocs/oauth/services/base.py
Outdated
@@ -226,6 +226,19 @@ def get_paginated_results(self, response): | |||
""" | |||
raise NotImplementedError | |||
|
|||
def get_provider_data(self, project, integration): | |||
""" | |||
Gets provider data from GitHub Webhooks API. |
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.
This shouldn't mention GitHub, as it's on the base class.
@stsewd Would love your take on this -- I think it's a better approach, but could use a bit more review. |
@ericholscher I'll try to review this today |
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 👍
I removed some dead code and updated the docs.
So, looks like we are not updating the secret on resync anymore. But looks like we found a better pattern to remove the secret if something failed p: If we go for not update the secret on resync, we need to update our docs https://docs.readthedocs.io/en/stable/webhooks.html#payload-validation
@stsewd Thanks for the update looks good :) |
Yea, we should update the doc in this PR then 👍 |
Done, feel free to merge :) |
closes: #6123
ref: #6122