From af350733655265c5ffce70242a0783af9b86396c Mon Sep 17 00:00:00 2001 From: Christinarlong Date: Tue, 9 Dec 2025 14:27:31 -0800 Subject: [PATCH 1/2] remove frozen dataclass due to task/dict behavior --- src/sentry/notifications/platform/service.py | 14 -------------- .../platform/templates/custom_rule.py | 4 ++-- .../platform/templates/data_export.py | 8 ++++---- .../platform/templates/repository.py | 4 ++-- .../platform/templates/sample.py | 19 ++++++++++--------- 5 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/sentry/notifications/platform/service.py b/src/sentry/notifications/platform/service.py index 1fba0a8a269011..5218a4f0782ef9 100644 --- a/src/sentry/notifications/platform/service.py +++ b/src/sentry/notifications/platform/service.py @@ -42,10 +42,6 @@ def __init__(self, *, data: T): @staticmethod def has_access(organization: Organization | RpcOrganization, source: str) -> bool: if not features.has("organizations:notification-platform", organization): - logger.info( - "notification.platform.has_access.feature_flag_disabled", - extra={"organization_id": organization.id, "source": source}, - ) return False option_key = f"notifications.platform-rate.{source}" @@ -63,16 +59,6 @@ def has_access(organization: Organization | RpcOrganization, source: str) -> boo return False modulo_result = sample_modulo(option_key, organization.id) - logger.info( - "notification.platform.has_access.sample_modulo", - extra={ - "organization_id": organization.id, - "source": source, - "option_key": option_key, - "modulo_result": modulo_result, - "sample_rate": options.get(option_key), - }, - ) return modulo_result def notify_target(self, *, target: NotificationTarget) -> None: diff --git a/src/sentry/notifications/platform/templates/custom_rule.py b/src/sentry/notifications/platform/templates/custom_rule.py index 623c5e3e694ff3..b6e187ab1853f4 100644 --- a/src/sentry/notifications/platform/templates/custom_rule.py +++ b/src/sentry/notifications/platform/templates/custom_rule.py @@ -18,14 +18,14 @@ def format_datetime(dt: datetime) -> str: return dt.strftime("%Y-%m-%d %H:%M:%S") -@dataclass(frozen=True) +@dataclass class CustomRuleSamplesFulfilled(NotificationData): - source = "custom-rule-samples-fulfilled" query: str | None num_samples: int start_date: datetime end_date: datetime discover_link: str + source: str = "custom-rule-samples-fulfilled" @template_registry.register(CustomRuleSamplesFulfilled.source) diff --git a/src/sentry/notifications/platform/templates/data_export.py b/src/sentry/notifications/platform/templates/data_export.py index 581fc61febb547..c5f7f66a14d3eb 100644 --- a/src/sentry/notifications/platform/templates/data_export.py +++ b/src/sentry/notifications/platform/templates/data_export.py @@ -23,11 +23,11 @@ def format_date(date: datetime) -> str: return date.strftime("%I:%M %p on %B %d, %Y (%Z)") -@dataclass(frozen=True) +@dataclass class DataExportSuccess(NotificationData): - source = "data-export-success" export_url: str expiration_date: datetime + source: str = "data-export-success" @template_registry.register(DataExportSuccess.source) @@ -55,12 +55,12 @@ def render(self, data: DataExportSuccess) -> NotificationRenderedTemplate: ) -@dataclass(frozen=True) +@dataclass class DataExportFailure(NotificationData): - source = "data-export-failure" error_message: str error_payload: dict[str, Any] creation_date: datetime + source: str = "data-export-failure" @template_registry.register(DataExportFailure.source) diff --git a/src/sentry/notifications/platform/templates/repository.py b/src/sentry/notifications/platform/templates/repository.py index fcdc2c3dc940ba..159f125bfd10b8 100644 --- a/src/sentry/notifications/platform/templates/repository.py +++ b/src/sentry/notifications/platform/templates/repository.py @@ -12,12 +12,12 @@ ) -@dataclass(frozen=True) +@dataclass class UnableToDeleteRepository(NotificationData): - source = "unable-to-delete-repository" repository_name: str provider_name: str error_message: str + source: str = "unable-to-delete-repository" @template_registry.register(UnableToDeleteRepository.source) diff --git a/src/sentry/notifications/platform/templates/sample.py b/src/sentry/notifications/platform/templates/sample.py index fe8e55cb6cb3f8..24ba7eea9228fb 100644 --- a/src/sentry/notifications/platform/templates/sample.py +++ b/src/sentry/notifications/platform/templates/sample.py @@ -20,7 +20,7 @@ ) -@dataclass(frozen=True) +@dataclass class ErrorAlertData(NotificationData): source = "error-alert-service" error_type: str @@ -32,6 +32,7 @@ class ErrorAlertData(NotificationData): chart_url: str issue_url: str assign_url: str + source: str = "error-alert-service" @template_registry.register(ErrorAlertData.source) @@ -114,9 +115,8 @@ def render(self, data: ErrorAlertData) -> NotificationRenderedTemplate: ) -@dataclass(frozen=True) +@dataclass class DeploymentData(NotificationData): - source = "deployment-service" project_name: str version: str environment: str @@ -125,6 +125,7 @@ class DeploymentData(NotificationData): commit_message: str deployment_url: str rollback_url: str + source: str = "deployment-service" @template_registry.register(DeploymentData.source) @@ -184,9 +185,8 @@ def render(self, data: DeploymentData) -> NotificationRenderedTemplate: ) -@dataclass(frozen=True) +@dataclass class SlowLoadMetricAlertData(NotificationData): - source = "slow-load-metric-alert" alert_type: str severity: str project_name: str @@ -197,6 +197,7 @@ class SlowLoadMetricAlertData(NotificationData): threshold: str start_time: str chart_url: str + source: str = "slow-load-metric-alert" @template_registry.register(SlowLoadMetricAlertData.source) @@ -243,15 +244,15 @@ def render(self, data: SlowLoadMetricAlertData) -> NotificationRenderedTemplate: ) -@dataclass(frozen=True) +@dataclass class PerformanceAlertData(NotificationData): - source = "performance-monitoring" metric_name: str threshold: str current_value: str project_name: str chart_url: str investigation_url: str + source: str = "performance-monitoring" @template_registry.register(PerformanceAlertData.source) @@ -310,14 +311,14 @@ def render(self, data: PerformanceAlertData) -> NotificationRenderedTemplate: ) -@dataclass(frozen=True) +@dataclass class TeamUpdateData(NotificationData): - source = "team-communication" team_name: str update_type: str message: str author: str timestamp: str + source: str = "team-communication" @template_registry.register(TeamUpdateData.source) From 69cc41c1866d1c976520e05c79afad8e1e024a0c Mon Sep 17 00:00:00 2001 From: Christinarlong Date: Tue, 9 Dec 2025 15:24:47 -0800 Subject: [PATCH 2/2] remove frozen from dataclass --- src/sentry/notifications/platform/templates/sample.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sentry/notifications/platform/templates/sample.py b/src/sentry/notifications/platform/templates/sample.py index 24ba7eea9228fb..20bb090a435212 100644 --- a/src/sentry/notifications/platform/templates/sample.py +++ b/src/sentry/notifications/platform/templates/sample.py @@ -22,7 +22,6 @@ @dataclass class ErrorAlertData(NotificationData): - source = "error-alert-service" error_type: str error_message: str project_name: str