Skip to content

Conversation

@JoshFerge
Copy link
Member

This PR enables Sentry to automatically associate GitHub PRs and commit messages with Sentry issues when a full Sentry issue URL is included in the description.

Why:
Users can now simply paste the Sentry issue URL directly from their browser into PR descriptions or commit messages, improving convenience and discoverability of related issues without needing to manually extract short IDs.

What:

  • Adds a new regex to src/sentry/utils/groupreference.py to parse various Sentry issue URL formats.
  • Extends find_referenced_groups to extract both numeric and qualified short IDs from these URLs.
  • Adds comprehensive test coverage for URL-based issue references in commits and pull requests.
  • Preserves backward compatibility with existing "Fixes SENTRY-123" formats.

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

Allow users to reference Sentry issues by pasting the full issue URL
in addition to the qualified short ID. This supports multiple URL formats:

- https://sentry.io/organizations/{org}/issues/{id}/
- https://{domain}/organizations/{org}/issues/{id}/
- https://sentry.sentry.io/issues/{id}/

The ID can be either a numeric group ID or a qualified short ID (e.g., SENTRY-123).

Previously, users had to use the exact short ID format (e.g., 'Fixes SENTRY-123').
Now they can simply paste the issue URL from their browser, making it easier
to associate PRs and commits with Sentry issues.

Examples that now work:
- 'Fixes https://sentry.io/organizations/sentry/issues/123456/'
- 'n+1 issue\nhttps://sentry.sentry.io/issues/123456/'
- 'https://sentry.io/organizations/org/issues/SENTRY-123/'

Related: #106312

Co-authored-by: josh.ferge <[email protected]>
@cursor
Copy link
Contributor

cursor bot commented Jan 14, 2026

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 Jan 14, 2026
@JoshFerge
Copy link
Member Author

@sentry review

@JoshFerge
Copy link
Member Author

bugbot review

@JoshFerge
Copy link
Member Author

@cursoragent please fix pr comments

@cursor
Copy link
Contributor

cursor bot commented Jan 14, 2026

Perfect! I've fixed the critical bug identified by both bots. Here's what was changed:

Bug Fix Summary

Issue: Line 73 was using organization_id=org_id which doesn't exist on the Group model.

Fix: Changed to project__organization_id=org_id to correctly query through the project relationship.

Before:

group = Group.objects.get(id=int(issue_id), organization_id=org_id)

After:

group = Group.objects.get(id=int(issue_id), project__organization_id=org_id)

This fix ensures that when users paste Sentry issue URLs with numeric IDs (like https://sentry.sentry.io/issues/6884132327/), the code will correctly look up the Group by filtering through the project's organization relationship, instead of causing a FieldError.

The fix has been committed and pushed to the branch. The tests should continue to work correctly since they create groups with proper project-organization relationships. ✅


Open in Cursor Open in Web

The Group model doesn't have a direct organization_id field. Groups are
related to organizations through their project foreign key. This fixes
a FieldError that would occur when looking up groups by numeric ID from
Sentry issue URLs.

Fixes bug identified by @sentry[bot] and @cursor[bot]

Co-authored-by: josh.ferge <[email protected]>
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