-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
✨ feat(github): implement issue update webhook handler #100471
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(github): implement issue update webhook handler #100471
Conversation
3da0159
to
e434468
Compare
assignee_name = "@" + assignee_gh_name | ||
|
||
# Sync the assignment to Sentry | ||
sync_group_assignee_inbound_by_external_actor( |
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.
do we want to FF this? i am thinking through how we will FF all the features i am adding also per integration and can't think of a clean way to do this.
open to suggestions.
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.
Good call! yes, let's feature flag.
repository = event.get("repository", {}) | ||
repo_full_name = repository.get("full_name") | ||
issue_number = issue.get("number") | ||
assignee_gh_name = event.get("assignee", {}).get("login") |
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.
Potential bug: The code will raise an AttributeError
when the GitHub webhook payload contains "assignee": null
, as it attempts to call .get("login")
on a None
object.
-
Description: The expression
event.get("assignee", {}).get("login")
will raise anAttributeError
when processing a GitHub webhook for an unassigned issue. The GitHub API sends"assignee": null
in this scenario. Theevent.get("assignee", {})
call correctly returnsNone
instead of the default{}
, but the subsequent chained call to.get("login")
on thisNone
value causes the exception. This crashes the webhook handler before it reaches the intended validation logic that checks for a falsyassignee_gh_name
, preventing the synchronization of issue unassignments from GitHub. -
Suggested fix: Safely access the nested
login
value. First, retrieve theassignee
object usingassignee = event.get("assignee")
. Then, conditionally get thelogin
value, for example:assignee_gh_name = assignee.get("login") if assignee else None
.
severity: 0.75, confidence: 0.95
Did we get this right? 👍 / 👎 to inform future reviews.
e434468
to
2710e1f
Compare
groups: QuerySet[Group], integration: RpcIntegration | Integration | ||
) -> QuerySet[Group]: | ||
for group in groups: | ||
if not should_sync_assignee_inbound(group.organization): |
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 have to do this at this layer because this is where we actually get the organization for the first time 😞
f83000c
to
08a6007
Compare
08a6007
to
6e64d17
Compare
Issues attributed to commits in this pull requestThis pull request was merged and Sentry observed the following issues: |
Summary
Implements GitHub issue webhook handler to sync issue assignments between GitHub and Sentry. When a GitHub issue is assigned or unassigned, the webhook automatically updates the corresponding Sentry issue assignment using the external user mapping.
I do have this working E2E, but breaking this into chunks.
The payload we expect looks like:

https://docs.github.com/en/webhooks/webhook-events-and-payloads#issues
Changes
IssuesEventWebhook
handler class to process GitHub issue eventssync_group_assignee_inbound_by_external_actor
to sync assignments to Sentry groupsTechnical Details
The webhook handler:
Note: this is disabled from the start since i haven't updated the Github Integration config yet. It will come in a followup.
Legal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.