webhooks.js: Typescript: "organization" key missing in Webhook payload definitions
Using typescript, the webhook event payload type definitions do not match the actual payloads sent by Github.
Example
The handler for the check_suite.completed event receives an argument of type Webhook.WebhookEvent<Webhook.WebhookPayloadCheckSuite>
The Webhook.WebhookPayloadCheckSuite type is defined as:
type WebhookPayloadCheckSuite = {
action: string;
check_suite: WebhookPayloadCheckSuiteCheckSuite;
repository: PayloadRepository;
sender: WebhookPayloadCheckSuiteSender;
};
The actual received payload contains two extra fields which are missing from the type definition, these fields are installation and organization:
{
"action": "completed",
"check_suite": { ... },
"repository": { ... },
"sender": { ... },
"organization": { ... },
"installation": {
"id": 1234,
"node_id": "dummy_node_id"
}
}
The type definitions should be updated to match the responses provided by Github.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 21 (11 by maintainers)
Commits related to this issue
- fix(payload-examples): Add missing "organization" object Ref: octokit/webhooks.js#87 — committed to octokit/webhooks by wolfy1339 4 years ago
- fix(payload-examples): Add missing "organization" object Ref: octokit/webhooks.js#87 — committed to octokit/webhooks by wolfy1339 4 years ago
The
changesfield exist now:https://github.com/octokit/webhooks.js/blob/1804f39a7bff8c0ff2b6bf196ba3b21b803e53d4/index.d.ts#L2893-L2899
Regarding the original issue from @acazacu:
WebhookPayloadCheckSuitenow includes an optional key for"installation", but is still missing an"organization"key.https://github.com/octokit/webhooks.js/blob/1804f39a7bff8c0ff2b6bf196ba3b21b803e53d4/index.d.ts#L4134-L4140
This issue needs to be resolved in https://github.com/octokit/webhooks, either by adding more example payloads, or by parsing the payload tables on https://developer.github.com/v3/activity/events/types/, as discussed here: https://github.com/octokit/webhooks.js/issues/94. In that particular case, the Events API Payload table is not complete, but I can ask the docs team to complete it
@gr2m Alright, on it! Will keep this issue updated with the progress.
https://github.com/octokit/webhooks is scraping https://developer.github.com/v3/activity/events/types/ in a nightly cron job.
If the response for the check suite event is lacking fields, it would be great if you’d tell support@github.com. You can reference this issue and please keep us posted 🙏 Once the documentation are updated, this issue should be resolved within a day or two via automated pull requests
I have sent in a PR that fixes this specific case octokit/webhooks#184
If you are going to ask them, could they also include field
installation?if you look at GitHub docs for LabelEvent you will see
action,label, andchangesbut the definition missingchanges;Something else must be broken I guess.
Hey Oriol, I understand you are frustrated, but your commented is unnecessary snarky. Very few documentations out there are perfect, it’s a very hard job, and I know for a fact that GitHub’s documentation team is doing an incredible job with the resources they have available.
If you want to help out, the idea was mentioned that we should parse the payload tables instead of the examples, see https://github.com/octokit/webhooks.js/issues/94. This should resolve most of the problems that people run into, and updating the payloads tables if they are incorrect or lacking information will be an easy fix, the support team will very much appreciate people reporting problems with it.
Thanks ❤️
awesome, thanks! I’ll pull the details together tonight and open a support ticket.