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
1 change: 1 addition & 0 deletions src/sentry/sentry_apps/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class SentryAppWebhookHaltReason(StrEnum):
APP_DISABLED = "app_disabled"
INNER_TIMEOUT = "inner_timeout"
MISSING_GROUP = "missing_group"
MISSING_SERVICEHOOK = "missing_servicehook"


class SentryAppExternalRequestFailureReason(StrEnum):
Expand Down
3 changes: 2 additions & 1 deletion src/sentry/sentry_apps/tasks/sentry_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,8 @@ def send_webhooks(installation: RpcSentryAppInstallation, event: str, **kwargs:
"webhook_url": installation.sentry_app.webhook_url or "",
}
)
raise SentryAppSentryError(message=SentryAppWebhookFailureReason.MISSING_SERVICEHOOK)
lifecycle.record_halt(halt_reason=SentryAppWebhookHaltReason.MISSING_SERVICEHOOK)
return
if event not in servicehook.events:
lifecycle.add_extras(
{
Expand Down
11 changes: 4 additions & 7 deletions tests/sentry/sentry_apps/tasks/test_sentry_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -1658,23 +1658,20 @@ def test_does_not_send_if_no_service_hook_exists(
install = self.create_sentry_app_installation(
organization=self.project.organization, slug=sentry_app.slug
)
with pytest.raises(SentryAppSentryError):
workflow_notification(install.id, self.issue.id, "assigned", self.user.id)
workflow_notification(install.id, self.issue.id, "assigned", self.user.id)
assert not safe_urlopen.called

# SLO assertions
assert_failure_metric(
mock_record, SentryAppSentryError(SentryAppWebhookFailureReason.MISSING_SERVICEHOOK)
)
# APP_CREATE (success) -> UPDATE_WEBHOOK (success) -> GRANT_EXCHANGER (success) -> PREPARE_WEBHOOK (success) -> send_webhook (error)
assert_halt_metric(mock_record, SentryAppWebhookHaltReason.MISSING_SERVICEHOOK)
# APP_CREATE (success) -> UPDATE_WEBHOOK (success) -> GRANT_EXCHANGER (success) -> PREPARE_WEBHOOK (success) -> send_webhook (halt)
assert_count_of_metric(
mock_record=mock_record, outcome=EventLifecycleOutcome.STARTED, outcome_count=5
)
assert_count_of_metric(
mock_record=mock_record, outcome=EventLifecycleOutcome.SUCCESS, outcome_count=4
)
assert_count_of_metric(
mock_record=mock_record, outcome=EventLifecycleOutcome.FAILURE, outcome_count=1
mock_record=mock_record, outcome=EventLifecycleOutcome.FAILURE, outcome_count=0
)

@patch("sentry.integrations.utils.metrics.EventLifecycle.record_event")
Expand Down
Loading