Skip to content

feat(integrations): Create ExternalActor from public GH email opportunistically#116737

Merged
hobzcalvin merged 8 commits into
masterfrom
ea-from-gh-api
Jun 3, 2026
Merged

feat(integrations): Create ExternalActor from public GH email opportunistically#116737
hobzcalvin merged 8 commits into
masterfrom
ea-from-gh-api

Conversation

@hobzcalvin

Copy link
Copy Markdown
Contributor

Add CommitAuthor.public_email_queried_at to track if/when we've checked a given author's GH profile for a public email address.

For CommitAuthors pushing new commits (whether they're new or old), if we haven't checked their GH profile in the past 30 days, check and create an ExternalActor mapping if their public email maps to a Sentry user in the given org.

@hobzcalvin hobzcalvin requested review from a team as code owners June 2, 2026 22:24
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 2, 2026
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/migrations/1105_commitauthor_public_email_queried_at.py

for 1105_commitauthor_public_email_queried_at in sentry

--
-- Add field public_email_queried_at to commitauthor
--
ALTER TABLE "sentry_commitauthor" ADD COLUMN "public_email_queried_at" timestamp with time zone NULL;

# (e.g. GitHub) in an attempt to create an ExternalActor mapping. Null means
# never queried. Used to rate-limit these expensive lookups so we only retry
# stale authors. See sentry.integrations.github.tasks.query_commit_author_public_emails.
public_email_queried_at = models.DateTimeField(null=True)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to give this a hardcoded default date (maybe Jan 01, 2026) so that we can mark this column as not null? It will be overwritten once we start performing these checks, so might be worthwhile to avoid a null

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say sure, but I think the cost of backfilling a default for 5411672 rows (yikes!) makes it not worth it. There may be many rows where we never set this--I think a LOT of CommitAuthors are extremely old and no longer generating commits we care about, so they'll never be checked.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it depends if we care if the older rows just have the sentinel value forever. We don't really need to perform the backfill if we just set a static default for existing rows

Comment thread src/sentry/integrations/github/webhook.py
Comment thread src/sentry/integrations/github/tasks/query_commit_author_public_emails.py Outdated
@hobzcalvin hobzcalvin requested a review from wedamija June 3, 2026 18:36

@wedamija wedamija left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, I'll leave it up to you about whether you want to try and make the column not-nullable

Comment thread src/sentry/integrations/github/tasks/query_commit_author_public_emails.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ef8ec067411564643ee1d0b5105a55c9feca7de1. Configure here.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/migrations/1107_commitauthor_public_email_queried_at.py

for 1107_commitauthor_public_email_queried_at in sentry

--
-- Add field public_email_queried_at to commitauthor
--
ALTER TABLE "sentry_commitauthor" ADD COLUMN "public_email_queried_at" timestamp with time zone NULL;

@hobzcalvin hobzcalvin enabled auto-merge (squash) June 3, 2026 22:20
@hobzcalvin hobzcalvin merged commit 156241f into master Jun 3, 2026
86 checks passed
@hobzcalvin hobzcalvin deleted the ea-from-gh-api branch June 3, 2026 22:22
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.

2 participants