Skip to content

Conversation

giovanni-guidini
Copy link
Contributor

ticket: prevent-275

There are some assumptions in these changes:

  1. The URL for the settings of an org depends on the sentry_org.slug.
  2. github_org_name is not necessarily the same as sentry_org.slug
  3. Constructing such URL is non-trivial without the base URL for the Sentry instance
  4. It's OK to return any of the valid sentry orgs for a prevent-AI request

So based on those assumptions these changes include the URL for the org settings such that we can slap that URL in the "no consent given" message - that appears if you request @sentry review in a PR without giving the consent. We want this to add a clearer Call To Action in that message, making it more useful

Note: Point 4 in particular means that we might want to limit the consent_url return to cases where there's exactly 1 org found.

Copy link

linear bot commented Sep 1, 2025

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 1, 2025
@giovanni-guidini giovanni-guidini marked this pull request as ready for review September 1, 2025 13:30
@giovanni-guidini giovanni-guidini requested a review from a team as a code owner September 1, 2025 13:30
cursor[bot]

This comment was marked as outdated.

ticket: prevent-275

There are some assumptions in these changes:
1. The URL for the settings of an org depends on the `sentry_org.slug`.
2. `github_org_name` is not necessarily the same as `sentry_org.slug`
3. Constructing such URL is non-trivial without the base URL for the Sentry instance
4. It's OK to return _any_ of the valid sentry orgs for a prevent-AI request

So based on those assumptions these changes include the URL for the org settings such that we can slap that URL in the "no consent given" message - that appears if you request `@sentry review` in a PR without giving the consent.
We want this to add a clearer Call To Action in that message, making it more useful
for org_integration in org_integrations:
try:
org = Organization.objects.get(id=org_integration.organization_id)
if _can_use_prevent_ai_features(org):
return {"consent": True}
# If this is the last org we will return this URL as the consent URL
consent_url = org.absolute_url("/settings/organization/")
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Non-deterministic URL and Inconsistent Return Structure

This function's consent_url is non-deterministic when multiple organizations lack consent, as its value depends on the arbitrary processing order of integrations. Additionally, the return structure is inconsistent, including consent_url only when consent is False, which may cause issues for callers.

Fix in Cursor Fix in Web

@giovanni-guidini giovanni-guidini merged commit b799e14 into master Sep 3, 2025
63 checks passed
@giovanni-guidini giovanni-guidini deleted the gio/prevent-275 branch September 3, 2025 14:00
andrewshie-sentry pushed a commit that referenced this pull request Sep 9, 2025
ticket: prevent-275

There are some assumptions in these changes:
1. The URL for the settings of an org depends on the `sentry_org.slug`.
2. `github_org_name` is not necessarily the same as `sentry_org.slug`
3. Constructing such URL is non-trivial without the base URL for the
Sentry instance
4. It's OK to return _any_ of the valid sentry orgs for a prevent-AI
request

So based on those assumptions these changes include the URL for the org
settings such that we can slap that URL in the "no consent given"
message - that appears if you request `@sentry review` in a PR without
giving the consent. We want this to add a clearer Call To Action in that
message, making it more useful

**Note:** Point 4 in particular means that we might want to limit the
`consent_url` return to cases where there's exactly 1 org found.
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