-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix bug in github-app.ts #5039
Fix bug in github-app.ts #5039
Conversation
const installationId = `${ctx.payload.installation.id}`; | ||
const senderId = `${ctx.payload.sender.id}`; | ||
const user = await this.userDB.findUserByIdentity({ authProviderId: this.env.githubAppAuthProviderId, authId: accountId }); |
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.
accountId
is the target account id, e.g. from github.com/gitpod-io
. this are not valid coordinates for user accounts.
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.
Interesting. I'd love to learn more about the differences between ctx.payload.installation.account.id
and ctx.payload.sender.id
.
- From the docs you linked, I gather that
ctx.payload.installation.account.id
is the "account" on which the app is installed (e.g. can be an org, as you mentioned) - Who is
ctx.payload.sender.id
then? Is it the user that installed the app (e.g. a team member), or the user that triggered/caused the event? (e.g. a community contributor opening a new PR)
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.
See the documentation URL at L.90.
Taking a look! Many thanks. 👍 /werft run 👍 started the job as gitpod-build-at-github-app.1 |
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.
Changes look good to me, thanks!
However, I tried the following test:
- Connect my GitHub App to this PR
- Add a Project for https://github.com/jankeromnes/oops.git
- Rename repository to "oops2"
- ... the
cloneUrl
in the DB never got updated:
mysql> select name, cloneUrl from d_b_project;
+------+-----------------------------------------+
| name | cloneUrl |
+------+-----------------------------------------+
| oops | https://github.com/jankeromnes/oops.git |
+------+-----------------------------------------+
1 row in set (0.01 sec)
Did the rename listener work for you?
const installationId = `${ctx.payload.installation.id}`; | ||
const senderId = `${ctx.payload.sender.id}`; | ||
const user = await this.userDB.findUserByIdentity({ authProviderId: this.env.githubAppAuthProviderId, authId: accountId }); |
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.
Interesting. I'd love to learn more about the differences between ctx.payload.installation.account.id
and ctx.payload.sender.id
.
- From the docs you linked, I gather that
ctx.payload.installation.account.id
is the "account" on which the app is installed (e.g. can be an org, as you mentioned) - Who is
ctx.payload.sender.id
then? Is it the user that installed the app (e.g. a team member), or the user that triggered/caused the event? (e.g. a community contributor opening a new PR)
}); | ||
app.on('installation.deleted', async ctx => { | ||
const installationId = `${ctx.payload.installation.id}`; | ||
await this.appInstallationDB.recordUninstallation("github", 'platform', installationId); | ||
}); | ||
|
||
app.on('repository.renamed', async ctx => { |
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.
Interesting, where is this event type documented? I couldn't find it anywhere.
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.
Also, that's the repository
event with renamed
action. See the documentation URL above.
if (!installation) { | ||
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.
Q: Can this actually happen?
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.
At least the typings suggest it by declaring it optional.
cf. https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository
Hmm, maybe something is wrong with my GitHub App setup:
|
@jankeromnes, I just double-checked with the webhook events and they look good. Did you set the webhook URL properly? You can check the settings of the GH App for the event delivery status, maybe they are not 200 OK? This is a short version of what's received, and it was effective:
|
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
LGTM label has been added. Git tree hash: e1c13db6df568b815cc6524306a8dc680353f2aa
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: svenefftinge Associated issue: #4661 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 |
Hmm, I thought I did. I had set it to
Ah, very cool, I didn't know about that. Checking the event log, it seems that:
There was no event about the rename, apparently. Maybe that's an additional option that needs to be enabled in the GitHub App somewhere? 🤔 Anyway, glad this is now merged! 🚀 |
@jankeromnes, you've created the GH App after the |
@AlexTugarev Ah yes, I've duplicated permissions from https://github.com/organizations/gitpod-io/settings/apps/gitpod-staging-com/permissions. That would explain it! EDIT: Which additional permissions do I need to add? Also, we should probably add them to the staging app too, right? Maybe to the production app as well? |
First changes towards #4661