Closed oscard0m closed 1 year ago
This is a really good idea. Thank you so much!
My PC is currently low, and I may have to use my mobile phone to try and trigger the bot. So, my response may come in a bit late, and seem a little far-fetched
I'll be back shortly with the feedback
When I tried using the bot, by starring the repo it is installed on, since I don't have any way to verify which calls are being sent.
I have this error
AggregateError:
HttpError: Not found. May be due to lack of authentication. Reason: Handling a "star.created" event: an "installation" key is missing. The installation ID cannot be determined
at /var/task/node_modules/@octokit/request/dist-node/index.js:86:21
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Job.doExecute (/var/task/node_modules/bottleneck/light.js:405:18)
...and here's what is in the headers. I think the github signature headers too are missing, and I still haven't figured out why it like this. To fix this, sometime ago... I even tried installing and uninstalling the bot, nothing changed.
Cache-Control: public, max-age=0, must-revalidate
Content-Length: 441
Date: Sun, 26 Feb 2023 21:09:19 GMT
Server: Vercel
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
X-Vercel-Cache: MISS
X-Vercel-Id: iad1::iad1::vzdv8-1677445757568-185e06ffa020
I suggest you modify your code to get some extra logs after each of the tasks performed by your event handler to see when is this Not found
error happens. With the logs you shared it's not clear at what point is failing.
You can also debug your Probot app on your local machine, which makes it easier to get the details and debuggers to see how your code behaves. To test your app, you can simulate some events.
Okay, great! I'll try doing this, and take a look at the simulation of events.
But, I think the point where I run into an issue with testing it locally, is that when I run npm start
it just opens a new webpage on port 3000. I have no idea how to actually debug or what to check since it is just rendering the default probot UI, since I'm deploying the bot with vercel serverless function
Okay, great! I'll try doing this, and take a look at the simulation of events.
But, I think the point where I run into an issue with testing it locally, is that when I run
npm start
it just opens a new webpage on port 3000. I have no idea how to actually debug or what to check since it is just rendering the default probot UI, since I'm deploying the bot with vercel serverless function
Did you try following the steps in Probot's documentation? https://probot.github.io/docs/development/#running-the-app-locally
Sorry for cycling back late @oscard0m.
Yes, I've followed the steps in the robot documentation, but I kept getting a server error.
That's not the case though, as the problem is with the stars.created and .deleted webhook events. Anytime I perform these actions, I keep getting the authentication error.
I even went on to install the bot on a public repo, perhaps the reason why it wasn't working before as because it is installed on a private repository — still the same thing.
I even tried generating a new private key and changed my webhook secret. Nada.
Did you validate which of the calls to GitHub API is giving problems?: https://github.com/kaf-lamed-beyt/stargazer/issues/2#issue-1600195955
I think it would be interesting to check that. Also, can you share which permissions your GitHub App have? https://docs.github.com/en/apps/maintaining-github-apps/editing-a-github-apps-permissions
Yes, I have checked the requests that are throwing errors, and it is the stars.created and star.deleted events.
...and the repository/app permission is only using the metadata scope since all it needs is the information about the repository it is installed on. But, I may be wrong though;
Yes, I have checked the requests that are throwing errors, and it is the stars.created and star.deleted events.
This means this handler is the one giving problems but inside this handler, which Request to GitHub API via Octokit is giving problems? Can you check that?
Oh! okay lemme do that now
Okay, I just realized that i can't test locally without running into some issues. But, when I push, and I check the webhook events that are fired, these events, below are where errors are coming from, and I can't exactly pin point with exact method of octokit is causing it.
Okay, I just realized that i can't test locally without running into some issues. But, when I push, and I check the webhook events that are fired, these events, below are where errors are coming from, and I can't exactly pin point with exact method of octokit is causing it.
Maybe you can try adding some to extra logs as I pointed in a past comment?
You can also try small steps:
Okay... I'll do that and come back with feedback.
Might take a while — perhaps in the afternoon. 🙏🙏
Ah! Great! These steps you added sounds great. I'll go through them.
Okay, so I tried the option you mentioned — by commenting all the octokit instances in the handler function. The authentication error below persisted, nonetheless 👇🏼
AggregateError:
HttpError: Not found. May be due to lack of authentication. Reason: Handling a "star.created" event: an "installation" key is missing. The installation ID cannot be determined
at /var/task/node_modules/@octokit/request/dist-node/index.js:86:21
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Job.doExecute (/var/task/node_modules/bottleneck/light.js:405:18)
One thing I noticed; whenever I star the repo, a "watch.started"
webhook event is fired also — and it was succesful. Then, I thought "why not try the "watch.started"
event".
When I did, I got the same auth error, but in this case, it was peculiar to the watch event. The funny thing now is that the "star.created"
event fired successfully.
So now, I'm thinking the issue is from my probot installation — because, by default, I think probot handles the issue of authentication out-of-the-box for us, yeah?
I'll try setting up another probot app locally, if the is still persists, I'll reach out again.
Okay, so I tried the option you mentioned — by commenting all the octokit instances in the handler function. The authentication error below persisted, nonetheless 👇🏼
AggregateError: HttpError: Not found. May be due to lack of authentication. Reason: Handling a "star.created" event: an "installation" key is missing. The installation ID cannot be determined at /var/task/node_modules/@octokit/request/dist-node/index.js:86:21 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Job.doExecute (/var/task/node_modules/bottleneck/light.js:405:18)
One thing I noticed; whenever I star the repo, a
"watch.started"
webhook event is fired also — and it was succesful. Then, I thought "why not try the"watch.started"
event".When I did, I got the same auth error, but in this case, it was peculiar to the watch event. The funny thing now is that the
"star.created"
event fired successfully.So now, I'm thinking the issue is from my probot installation — because, by default, I think probot handles the issue of authentication out-of-the-box for us, yeah?
I'll try setting up another probot app locally, if the is still persists, I'll reach out again.
With this said, I suspect the auth token you are using is not correct. Make sure you configured it correctly. More details here: https://probot.github.io/docs/configuration/
Oh oh! great! I'll have a look now.
I had a look at my env variables. and they are exactly as is, in the documentation;
Although I'm deploying my bot on Vercel, I've added all the variables in the environment variables route in my Vercel dashboard, except the WEBHOOK_PROXY_URL
. Do I need to add it also?
So they are exactly the same as in your GitHub App settings?
Yes, actually.
Here you can find a version working: https://github.com/oscard0m/stargazer-test
I'm using the code but I had to use some adjustments. Using local development was quite easy to spot the issues.
I'm happy to schedule a session to pair-program on this and help you setup the local environment correctly and show you how to debug, etc.
Feel free to ask any question about my solutions
Wohooo!!
Thank you so much. I'll have a look now.
When will you be free for a session and what exactly was the error 😭
I am opening this issue where we can comment on your usecase. I think we are adding noise to this already existing discussion in Probot's repo: https://github.com/probot/probot/issues/1795
Your handler is doing 3 or 4 calls (depending on the conditionals) to GitHub's API:
context.octokit.issues.listForRepo
context.octokit.issues.create
context.octokit.users.getByUsername
context.octokit.issues.createComment
Can you validate which requests to the API are working and which one/s are giving you a 401? I think it's a good start to try to figure out this first of all.