Skip to content
Draft
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
4 changes: 4 additions & 0 deletions src/sentry/seer/autofix/issue_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from sentry.seer.entrypoints.operator import SeerAutofixOperator
from sentry.seer.models import SummarizeIssueResponse
from sentry.seer.models.run import SeerRun
from sentry.seer.seer_setup import has_seer_access
from sentry.seer.signed_seer_api import (
SeerViewerContext,
SummarizeIssueRequest,
Expand Down Expand Up @@ -425,6 +426,9 @@ def is_group_triggering_automation(group: Group) -> bool:
Checks if a group is going to be picked up for automation. Does not check for existing run.
Checks project options (fixability tuning, preferences), billing quota, and rate limiting.
"""
if not has_seer_access(group.organization):
return False

fixability_score = get_and_update_group_fixability_score(group)

if (
Expand Down
13 changes: 13 additions & 0 deletions src/sentry/seer/autofix/on_completion_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,19 @@ def _send_step_webhook(
"organization_id": organization.id,
}
)
else:
metrics.incr(
"autofix.on_completion_hook.process_autofix_updates.skipped",
tags={"reason": "no_operator_access", "event_type": str(event_type)},
)
logger.info(
"autofix.on_completion_hook.process_autofix_updates.skipped",
extra={
"organization_id": organization.id,
"event_type": str(event_type),
"reason": "no_operator_access",
},
)
except ValueError:
logger.exception(
"autofix.on_completion_hook.webhook_invalid_event_type",
Expand Down
34 changes: 34 additions & 0 deletions tests/sentry/seer/autofix/test_autofix_on_completion_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,40 @@ def test_send_step_webhook_pr_iteration(
== AutofixReferrer.GROUP_AUTOFIX_ENDPOINT.value
)

@patch("sentry.seer.autofix.on_completion_hook.logger.info")
@patch("sentry.seer.autofix.on_completion_hook.metrics.incr")
@patch("sentry.seer.autofix.on_completion_hook.process_autofix_updates.apply_async")
@patch(
"sentry.seer.autofix.on_completion_hook.SeerAutofixOperator.has_access", return_value=False
)
@patch("sentry.seer.autofix.on_completion_hook.broadcast_webhooks_for_organization.delay")
def test_records_skipped_processing_without_operator_access(
self, mock_broadcast, mock_has_access, mock_process_autofix_updates, mock_incr, mock_info
):
run_id = 123
self.create_seer_run(organization=self.organization, seer_run_state_id=run_id)

AutofixOnCompletionHook._send_step_webhook(
self.organization,
run_id,
run_state(blocks=[root_cause_memory_block()]),
self.group,
)

mock_process_autofix_updates.assert_not_called()
mock_incr.assert_any_call(
"autofix.on_completion_hook.process_autofix_updates.skipped",
tags={"reason": "no_operator_access", "event_type": "seer.root_cause_completed"},
)
mock_info.assert_called_once_with(
"autofix.on_completion_hook.process_autofix_updates.skipped",
extra={
"organization_id": self.organization.id,
"event_type": "seer.root_cause_completed",
"reason": "no_operator_access",
},
)

@patch("sentry.seer.autofix.on_completion_hook.analytics.record")
@patch("sentry.seer.autofix.on_completion_hook.broadcast_webhooks_for_organization.delay")
def test_send_step_webhook_pr_iteration_does_not_emit_pr_created(
Expand Down
7 changes: 7 additions & 0 deletions tests/sentry/seer/autofix/test_issue_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,13 @@ def test_returns_true_when_all_checks_pass(self, mock_fixability, mock_quota, mo

assert is_group_triggering_automation(self.group) is True

@patch("sentry.seer.autofix.issue_summary.get_and_update_group_fixability_score")
def test_returns_false_without_seer_access(self, mock_fixability):
with self.feature({"organizations:gen-ai-features": False}):
assert is_group_triggering_automation(self.group) is False

mock_fixability.assert_not_called()

@patch("sentry.seer.autofix.issue_summary.get_and_update_group_fixability_score")
def test_returns_false_when_not_fixable(self, mock_fixability):
mock_fixability.return_value = 0.20
Expand Down
Loading