Skip to content
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: determine webhook path for createNodeMiddleware() via env variable #1881

Merged
merged 1 commit into from Nov 14, 2023

Conversation

Uzlopak
Copy link
Collaborator

@Uzlopak Uzlopak commented Nov 10, 2023

Fixes #1878

When using probot 13 beta i realized that it was totally unintuitive that setting the WEBHOOK_PATH had no effect on our bots.

@Uzlopak Uzlopak requested a review from a team as a code owner November 10, 2023 15:43
@Uzlopak Uzlopak changed the base branch from master to beta November 10, 2023 15:43
@Uzlopak
Copy link
Collaborator Author

Uzlopak commented Nov 10, 2023

I prefer the singular form WEBHOOK_PATH.

webhooksPath comes from the @probot/webhooks package.

Just for some background:
We use probot for our bots in combination with google cloud functions. I upgraded to probot 13 and needed to set the webhook path. So i set it as environment variable WEBHOOK_PATH but the trigger was still /api/github/webhooks.
So I realized it is not picking up the path from the env variable.

So we used webhooksPath option. The PR makes it possible that probot picks up the webhooks path from the env variable.

src/create-probot.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

I think this pull request does more than necessary. I agree with the first test but the 2nd test is odd, all environment variables should be set explicitly as the env argument in createProbot(), no other process.env.* variables should matter, it would result in unforeseen side effects

@Uzlopak
Copy link
Collaborator Author

Uzlopak commented Nov 11, 2023

@gr2m

Implemented as requested. ;)

Copy link
Contributor

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

I'm still a bit unsure about exposing probot.webhookPath. The path on with webhook requests are received does not logically belong to the probot instance, it belongs to whatever mechanism is used to receive requests, such as createNodeMiddleware or the express server.

Sorry for making this hard, I try to avoid a future breaking change. Once we introduce probot.webhookPath we cannot remove it. I think we should try to solve this in a way that does not require any changes to to create-probot.ts

@gr2m
Copy link
Contributor

gr2m commented Nov 12, 2023

if possible, can you avoid force-pushing to pull requests once reviews started? It makes it harder to keep track of progress. PRs can get messy as they need be, we will squash them at the end anyway

@Uzlopak Uzlopak changed the title Determine webhook path for createNodeModules via env variable Determine webhook path for createNodeMiddleware via env variable Nov 12, 2023
@Uzlopak
Copy link
Collaborator Author

Uzlopak commented Nov 12, 2023

Sry regarding forced pushing. Kind of bad habit from creating PRs for nodejs.

When I am at home I will check again. I just want to be able to overwrite the webhookPath via env variable when using createNodeMiddleware.

@gr2m
Copy link
Contributor

gr2m commented Nov 12, 2023

I just want to be able to overwrite the webhookPath via env variable when using createNodeMiddleware.

maybe we should move reading that env variable into createNodeMiddleware?

@Uzlopak
Copy link
Collaborator Author

Uzlopak commented Nov 13, 2023

@gr2m

I really invested now multiple hours on this, but your request is contradictive.

createProbot has the env option, where I need to pass WEBHOOK_PATH. So I would expect that that env would handle WEBHOOK_PATH properly. So it has to expose the knowledge somehow.

The only other solution I can propose is to make the state attribute of probot public and make it start with _ to indicate it is internal api and the api contract is not ensured.

Copy link
Contributor

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

okay I'm sorry I rather not have you frustrated, I don't mind getting this merged, we can revise in the future if needed, but for now lets ship it

@gr2m gr2m changed the title Determine webhook path for createNodeMiddleware via env variable fix: determine webhook path for createNodeMiddleware() via env variable Nov 14, 2023
@gr2m gr2m merged commit 753c71b into probot:beta Nov 14, 2023
8 checks passed
Copy link

🎉 This PR is included in version 13.0.0-beta.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WEBHOOKS_PATH vs. WEBHOOK_PATH
2 participants