Skip to content

Conversation

@armenzg
Copy link
Member

@armenzg armenzg commented Dec 5, 2025

This PR introduces comprehensive TypedDict definitions for GitHub webhook events in src/sentry/integrations/github/webhook_types.py.

The primary goal is to enhance type safety, improve developer experience with better autocomplete, and provide clearer documentation of expected webhook payload structures within the GitHub integration.

Key changes include:

  • Defining detailed TypedDict classes for common GitHub objects (e.g., GitHubUser, GitHubRepository, GitHubPullRequest) and specific webhook event types (e.g., PushWebhookEvent, PullRequestWebhookEvent).
  • Updating src/sentry/integrations/github/webhook.py to leverage these new types.
  • Ensuring mypy passes by strategically using Mapping[str, Any] in public method signatures (to maintain compatibility with parent classes) and casting to specific TypedDict types internally for more precise type checking.
  • The changes are backward compatible and do not alter runtime behavior, focusing solely on static type analysis benefits.

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.


Slack Thread

Open in Cursor Open in Web

Co-authored-by: armenzg <armenzg@sentry.io>
@cursor
Copy link
Contributor

cursor bot commented Dec 5, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Dec 5, 2025
@codecov
Copy link

codecov bot commented Dec 5, 2025

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
30203 2 30201 240
View the top 2 failed test(s) by shortest run time
tests.sentry.integrations.github.test_webhooks.InstallationEventWebhookTest::test_installation_created
Stack Traces | 0.296s run time
#x1B[1m#x1B[.../integrations/github/test_webhooks.py#x1B[0m:123: in test_installation_created
    assert integration.metadata["sender"]["id"] == 1
#x1B[1m#x1B[31mE   AssertionError: assert '1' == 1#x1B[0m
tests.sentry.integrations.github.test_installation.InstallationEndpointTest::test_installation_endpoint
Stack Traces | 0.422s run time
#x1B[1m#x1B[.../integrations/github/test_installation.py#x1B[0m:55: in test_installation_endpoint
    assert body["sender"]["id"] == 1
#x1B[1m#x1B[31mE   AssertionError: assert '1' == 1#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

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

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants