Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

fix(batches): switch github app installation handling from redirect flow to webhooks#64036

Merged
bahrmichael merged 22 commits into
mainfrom
bahrmichael/bc-ghapp-webhook
Jul 26, 2024
Merged

fix(batches): switch github app installation handling from redirect flow to webhooks#64036
bahrmichael merged 22 commits into
mainfrom
bahrmichael/bc-ghapp-webhook

Conversation

@bahrmichael

@bahrmichael bahrmichael commented Jul 24, 2024

Copy link
Copy Markdown
Contributor

Closes SRCH-741
Closes SRCH-716

This PR removes the GitHub installation code from the redirect flow to a webhook-based appraoch. We expect that the GitHub server calls the webhook when the installation is ready, and therefore shouldn't see the errors explained in the issues above.

To handle the potential delay until the webhook is called and the credential is set up, I added a scrappy info notice that the user should refresh their page:

Screenshot 2024-07-24 at 13 48 24

Below is what you see after you refreshed (or if the webhook was called faster than the user being redirected back to the settings):

Screenshot 2024-07-24 at 13 50 14

I'm able to create PRs for sourcegraph-testing with an app that was created this way.

Screenshot 2024-07-24 at 16 16 06

I'm seeing an error when getting an access token with a personal github app to run a batch change, but that will be handled with another PR.

Screenshot 2024-07-24 at 16 38 38

Test plan

Manual testing locally, and more testing to be done on S2 where we have a more production like environment

Changelog

  • When installing a GitHub app for batch changes, the instance now waits for a callback from GitHub to complete the installation to avoid issues from eventual consistency.

@cla-bot cla-bot Bot added the cla-signed label Jul 24, 2024
@bahrmichael bahrmichael marked this pull request as ready for review July 24, 2024 14:57
@bahrmichael bahrmichael requested review from a team and BolajiOlajide July 24, 2024 14:57
@bahrmichael bahrmichael changed the title fix(batch changes): move github app installation handling from redirect flow to webhooks fix(batch changes): switch github app installation handling from redirect flow to webhooks Jul 24, 2024

@peterguy peterguy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be much more reliable than the sleep approach :-D

Comment thread client/web/src/enterprise/batches/settings/CodeHostConnections.tsx Outdated
@bahrmichael

Copy link
Copy Markdown
Contributor Author

Should be much more reliable than the sleep approach :-D

To be honest, that doesn't remove the sleep approach. It's just a way to deal with eventual consistency between the sourcegraph instance and github.

@bahrmichael bahrmichael changed the title fix(batch changes): switch github app installation handling from redirect flow to webhooks fix(batches): switch github app installation handling from redirect flow to webhooks Jul 26, 2024
@bahrmichael bahrmichael enabled auto-merge (squash) July 26, 2024 11:28
@bahrmichael bahrmichael merged commit 3ff0ddf into main Jul 26, 2024
@bahrmichael bahrmichael deleted the bahrmichael/bc-ghapp-webhook branch July 26, 2024 11:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants