-
Notifications
You must be signed in to change notification settings - Fork 83
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
feat: deprecate onUnhandledRequest
and accepting object payloads for for webhooks.verify()
and webhooks.verifyAndReceive()
#790
Conversation
The deprecations still need to be added to the middleware. |
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! ❤️ Thanks for getting these issues knocked out!
🎉 This PR is included in version 10.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 11.0.0-beta.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@@ -12,9 +12,15 @@ export function createNodeMiddleware( | |||
log = createLogger(), | |||
}: MiddlewareOptions = {} | |||
) { | |||
const deprecateOnUnhandledRequest = (request: any, response: any) => { | |||
console.error( |
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.
I know this has been merged, but shouldn't this be a warning instead of an error? It being an error seems to confuse Jest in some tests I run, and a warning would fit here better in my opinion.
Should this example be updated? How do we do the equivalent of this with just a string? |
Simply don't pass the string received into |
I see payload can't be an object. this.source = new EventSource(webhookProxyUrl);
this.source.onmessage = (event) => {
const webhookEvent = JSON.parse(event.data);
this.app.webhooks
.verifyAndReceive({
id: webhookEvent["x-request-id"],
name: webhookEvent["x-github-event"],
payload: JSON.stringify(webhookEvent.body), // <= HERE
signature: webhookEvent["x-hub-signature"]
})
.catch(console.error);
}; |
What version of What is the exact message you are getting and from where? I don't see why it would error |
I don't see why it would error
When I pass object instead of string the payload in
|
I cannot reproduce this issue. The following code works for me const { App } = require('octokit'); // Octokit.js v2.0.15 and v2.0.16
const EventSource = require('eventsource');
const webhookProxyUrl = "https://smee.io/IrqK0nopGAOc847";
const source = new EventSource(webhookProxyUrl);
const app = new App({
appId: 95608,
privateKey: readFileSync('./private-key.pem').toString(),
webhooks: {
secret: 'thisismysecret'
}
});
source.onmessage = (event) => {
const webhookEvent = JSON.parse(event.data);
app.webhooks
.verifyAndReceive({
id: webhookEvent["x-request-id"],
name: webhookEvent["x-github-event"],
signature: webhookEvent["x-hub-signature"],
payload: JSON.stringify(webhookEvent.body),
})
.catch(console.error);
}; |
If this isn't a string the warning will appear. Ex: |
That is the intended behaviour |
Resolves #784
Resolves #589
See also #775
Behavior
Before the change?
onUnhandledRequest
option was not deprecatedAfter the change?
onUnhandledRequest
optionOther information
Additional info
Pull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!
Type: Breaking change
label)If
Yes
, what's the impact:Pull request type
Please add the corresponding label for change this PR introduces:
Type: Bug
Type: Feature
Type: Documentation
Type: Maintenance