Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/sentry/seer/endpoints/group_autofix_setup_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.conf import settings
from rest_framework.response import Response

from sentry import quotas
from sentry import features, quotas
from sentry.api.api_owners import ApiOwner
from sentry.api.api_publish_status import ApiPublishStatus
from sentry.api.base import region_silo_endpoint
Expand Down Expand Up @@ -135,6 +135,15 @@ def get(self, request: Request, group: Group) -> Response:
organization=org, project=group.project
)

# Customers on new pricing need to have github configured to use Autofix.
# Check if project has code mappings configured (feature flagged)
if integration_check is None and features.has(
"organizations:triage-signals-v0-org", org
):
repos_from_mappings = get_autofix_repos_from_project_code_mappings(group.project)
if not repos_from_mappings:
integration_check = "code_mappings_missing"

write_integration_check = None
if request.query_params.get("check_write_access", False):
repos = get_repos_and_access(group.project, group.id)
Expand Down
5 changes: 5 additions & 0 deletions src/sentry/tasks/post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,7 @@ def kick_off_seer_automation(job: PostProcessJob) -> None:
get_issue_summary_lock_key,
)
from sentry.seer.autofix.utils import (
get_autofix_repos_from_project_code_mappings,
is_issue_eligible_for_seer_automation,
is_seer_scanner_rate_limited,
)
Expand Down Expand Up @@ -1683,6 +1684,10 @@ def kick_off_seer_automation(job: PostProcessJob) -> None:
if not is_issue_eligible_for_seer_automation(group):
return

# Check if project has connected repositories - requirement for new pricing
if not get_autofix_repos_from_project_code_mappings(group.project):
return

# Atomically set cache to prevent duplicate dispatches (returns False if key exists)
automation_dispatch_cache_key = f"seer-automation-dispatched:{group.id}"
if not cache.add(automation_dispatch_cache_key, True, timeout=300):
Expand Down
15 changes: 13 additions & 2 deletions tests/sentry/tasks/test_post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -3108,12 +3108,16 @@ def test_triage_signals_event_count_less_than_10_with_cache(
"sentry.seer.seer_setup.get_seer_org_acknowledgement_for_scanner",
return_value=True,
)
@patch(
"sentry.seer.autofix.utils.get_autofix_repos_from_project_code_mappings",
return_value=[{"name": "test-repo"}],
)
@patch("sentry.tasks.autofix.run_automation_only_task.delay")
@with_feature(
{"organizations:gen-ai-features": True, "organizations:triage-signals-v0-org": True}
)
def test_triage_signals_event_count_gte_10_with_cache(
self, mock_run_automation, mock_get_seer_org_acknowledgement
self, mock_run_automation, mock_get_repos, mock_get_seer_org_acknowledgement
):
"""Test that with event count >= 10 and cached summary exists, we run automation directly."""
self.project.update_option("sentry:seer_scanner_automation", True)
Expand Down Expand Up @@ -3157,12 +3161,19 @@ def mock_buffer_get(model, columns, filters):
"sentry.seer.seer_setup.get_seer_org_acknowledgement_for_scanner",
return_value=True,
)
@patch(
"sentry.seer.autofix.utils.get_autofix_repos_from_project_code_mappings",
return_value=[{"name": "test-repo"}],
)
@patch("sentry.tasks.autofix.generate_summary_and_run_automation.delay")
@with_feature(
{"organizations:gen-ai-features": True, "organizations:triage-signals-v0-org": True}
)
def test_triage_signals_event_count_gte_10_no_cache(
self, mock_generate_summary_and_run_automation, mock_get_seer_org_acknowledgement
self,
mock_generate_summary_and_run_automation,
mock_get_repos,
mock_get_seer_org_acknowledgement,
):
"""Test that with event count >= 10 and no cached summary, we generate summary + run automation."""
self.project.update_option("sentry:seer_scanner_automation", True)
Expand Down
Loading