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

sender key in webhooks #510

Closed
gr2m opened this issue Jun 19, 2021 · 2 comments
Closed

sender key in webhooks #510

gr2m opened this issue Jun 19, 2021 · 2 comments
Projects

Comments

@gr2m
Copy link
Contributor

gr2m commented Jun 19, 2021

The sender key is not present e.g. in CheckRunCreatedEvent:

export interface CheckRunCreatedEvent {
action: "created";
/**
* The [check_run](https://docs.github.com/en/rest/reference/checks#get-a-check-run).
*/
check_run: {
/**
* The id of the check.
*/
id: number;
node_id?: string;
/**
* The SHA of the commit that is being checked.
*/
head_sha: string;
external_id: string;
url: string;
html_url: string;
details_url?: string;
/**
* The current status of the check run. Can be `queued`, `in_progress`, or `completed`.
*/
status: "queued" | "in_progress" | "completed";
/**
* The result of the completed check run. Can be one of `success`, `failure`, `neutral`, `cancelled`, `timed_out`, `action_required` or `stale`. This value will be `null` until the check run has completed.
*/
conclusion:
| "success"
| "failure"
| "neutral"
| "cancelled"
| "timed_out"
| "action_required"
| "stale"
| "skipped"
| null;
/**
* The time that the check run began. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
*/
started_at: string;
/**
* The time the check completed. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
*/
completed_at: string | null;
output: {
title?: string | null;
summary: string | null;
text: string | null;
annotations_count: number;
annotations_url: string;
};
/**
* The name of the check run.
*/
name: string;
check_suite: {
/**
* The id of the check suite that this check run is part of.
*/
id: number;
node_id?: string;
head_branch: string | null;
/**
* The SHA of the head commit that is being checked.
*/
head_sha: string;
status: "queued" | "in_progress" | "completed";
conclusion:
| "success"
| "failure"
| "neutral"
| "cancelled"
| "timed_out"
| "action_required"
| "stale"
| null;
url: string;
before: string | null;
after: string | null;
/**
* An array of pull requests that match this check suite. A pull request matches a check suite if they have the same `head_sha` and `head_branch`. When the check suite's `head_branch` is in a forked repository it will be `null` and the `pull_requests` array will be empty.
*/
pull_requests: CheckRunPullRequest[];
deployment?: CheckRunDeployment;
app: App;
created_at: string;
updated_at: string;
};
app: App;
pull_requests: CheckRunPullRequest[];
};
/**
* The action requested by the user.
*/
requested_action?: {
/**
* The integrator reference of the action requested by the user.
*/
identifier?: string;
} | null;
repository: Repository;
sender: User;
installation?: InstallationLite;
organization?: Organization;
}

The example for the check_run.created event has the "sender" key

"sender": {
"login": "Codertocat",
"id": 21031067,
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
"avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Codertocat",
"html_url": "https://github.com/Codertocat",
"followers_url": "https://api.github.com/users/Codertocat/followers",
"following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
"gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
"organizations_url": "https://api.github.com/users/Codertocat/orgs",
"repos_url": "https://api.github.com/users/Codertocat/repos",
"events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/Codertocat/received_events",
"type": "User",
"site_admin": false
}

I'm not sure, but I'd assume a sender would always be present? I ran into this as I was working on probot/probot#1559

image

Do you know more about this? Happy to inquire with GitHub's Events team

@gr2m gr2m added the support label Jun 19, 2021
@ghost ghost added this to Support in JS Jun 19, 2021
@wolfy1339
Copy link
Member

The sender key is not present e.g. in CheckRunCreatedEvent

It is present for that event, I double checked. If it wouldn't be, the tests wouldn't pass, as the payload contains the sender.
The error from TS is a bit misleading, but it is correct. The sender property is not present in the union of ALL events

Do you know more about this? Happy to inquire with GitHub's Events team

Here is a list of events (schema $ids) which do not have a sender property:

  • secret_scanning_alert$created (Missing example payload)
  • security_advisory$performed (Missing example payload)
  • security_advisory$published
  • security_advisory$updated
  • security_advisory$withdrawn

@gr2m
Copy link
Contributor Author

gr2m commented Jun 23, 2021

I got feedback on that: security_advisory does not have a sender key because there is no actor. And there are no plans at this point to a new type of actor for GitHub itself. So we will have to live with the fact that sender will be conditional.

@gr2m gr2m closed this as completed Jun 23, 2021
JS automation moved this from Support to Done Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
JS
  
Done
Development

No branches or pull requests

2 participants