prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Unable to disable issue alert notifications for specific projects on old sentry accounts.
  ### Environment
  
  SaaS (https://sentry.io/)
  
  ### Version
  
  _No response_
  
  ### Link
  
  _No response_
  
  ### DSN
  
  _No response_
  
  ### Steps to Reproduce
  
  In old accounts the default option for Fine tuning issue alert notifications was `--`, which no longer exists. (User Settings -> Notifications -> Issue alert notifications -> Fine Tune).
  
  It seems to have been replaced with "Default" and in cases a user wants to disable the notifications for a project that currently has `--` selected, the changes to "Off" is not saved and notifications continue to be sent. 
  
  There is no workaround as turning issue alerts notifications to OFF completely disable the notifications for all projects in all organisation, not allowing to enable for projects that man wants to receive notifications from. 
  
  As a side note: This design is not optimal as having "On" and "Default" is redundant -> you can only set default to On, and when it is off there are no options available (Default(Off) does not exist). 
  
  There is a recoding available in this [internal ticket (contains personal information)](https://sentry.zendesk.com/agent/tickets/84240)
  
  ### Expected Result
  
  Changing the notification from `--` to `Off` saves and stop sending emails.
  
  ### Actual Result
  
  The change is not saved.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/sentry/incidents/endpoints/bases.py`
  Content:
  ```
  1 from rest_framework.exceptions import PermissionDenied
  2 from rest_framework.request import Request
  3 
  4 from sentry import features
  5 from sentry.api.bases.organization import OrganizationAlertRulePermission, OrganizationEndpoint
  6 from sentry.api.bases.project import ProjectAlertRulePermission, ProjectEndpoint
  7 from sentry.api.exceptions import ResourceDoesNotExist
  8 from sentry.incidents.models import AlertRule, AlertRuleTrigger, AlertRuleTriggerAction
  9 
  10 
  11 class ProjectAlertRuleEndpoint(ProjectEndpoint):
  12     permission_classes = (ProjectAlertRulePermission,)
  13 
  14     def convert_args(self, request: Request, alert_rule_id, *args, **kwargs):
  15         args, kwargs = super().convert_args(request, *args, **kwargs)
  16         project = kwargs["project"]
  17 
  18         if not features.has("organizations:incidents", project.organization, actor=request.user):
  19             raise ResourceDoesNotExist
  20 
  21         if not request.access.has_project_access(project):
  22             raise PermissionDenied
  23 
  24         try:
  25             kwargs["alert_rule"] = AlertRule.objects.get(
  26                 snuba_query__subscriptions__project=project, id=alert_rule_id
  27             )
  28         except AlertRule.DoesNotExist:
  29             raise ResourceDoesNotExist
  30 
  31         return args, kwargs
  32 
  33 
  34 class OrganizationAlertRuleEndpoint(OrganizationEndpoint):
  35     permission_classes = (OrganizationAlertRulePermission,)
  36 
  37     def convert_args(self, request: Request, alert_rule_id, *args, **kwargs):
  38         args, kwargs = super().convert_args(request, *args, **kwargs)
  39         organization = kwargs["organization"]
  40 
  41         # Allow orgs that have downgraded plans to delete metric alerts
  42         if request.method != "DELETE" and not features.has(
  43             "organizations:incidents", organization, actor=request.user
  44         ):
  45             raise ResourceDoesNotExist
  46 
  47         try:
  48             kwargs["alert_rule"] = AlertRule.objects.get(
  49                 organization=organization, id=alert_rule_id
  50             )
  51         except AlertRule.DoesNotExist:
  52             raise ResourceDoesNotExist
  53 
  54         return args, kwargs
  55 
  56 
  57 class OrganizationAlertRuleTriggerEndpoint(OrganizationAlertRuleEndpoint):
  58     def convert_args(self, request: Request, alert_rule_trigger_id, *args, **kwargs):
  59         args, kwargs = super().convert_args(request, *args, **kwargs)
  60         organization = kwargs["organization"]
  61         alert_rule = kwargs["alert_rule"]
  62 
  63         if not features.has("organizations:incidents", organization, actor=request.user):
  64             raise ResourceDoesNotExist
  65 
  66         try:
  67             kwargs["alert_rule_trigger"] = AlertRuleTrigger.objects.get(
  68                 alert_rule=alert_rule, id=alert_rule_trigger_id
  69             )
  70         except AlertRuleTrigger.DoesNotExist:
  71             raise ResourceDoesNotExist
  72 
  73         return args, kwargs
  74 
  75 
  76 class OrganizationAlertRuleTriggerActionEndpoint(OrganizationAlertRuleTriggerEndpoint):
  77     def convert_args(self, request: Request, alert_rule_trigger_action_id, *args, **kwargs):
  78         args, kwargs = super().convert_args(request, *args, **kwargs)
  79         organization = kwargs["organization"]
  80         trigger = kwargs["alert_rule_trigger"]
  81 
  82         if not features.has("organizations:incidents", organization, actor=request.user):
  83             raise ResourceDoesNotExist
  84 
  85         try:
  86             kwargs["alert_rule_trigger_action"] = AlertRuleTriggerAction.objects.get(
  87                 alert_rule_trigger=trigger, id=alert_rule_trigger_action_id
  88             )
  89         except AlertRuleTriggerAction.DoesNotExist:
  90             raise ResourceDoesNotExist
  91 
  92         return args, kwargs
  93
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/sentry/incidents/endpoints/bases.py b/src/sentry/incidents/endpoints/bases.py
  --- a/src/sentry/incidents/endpoints/bases.py
  +++ b/src/sentry/incidents/endpoints/bases.py
  @@ -15,7 +15,10 @@
           args, kwargs = super().convert_args(request, *args, **kwargs)
           project = kwargs["project"]
   
  -        if not features.has("organizations:incidents", project.organization, actor=request.user):
  +        # Allow orgs that have downgraded plans to delete metric alerts
  +        if request.method != "DELETE" and not features.has(
  +            "organizations:incidents", project.organization, actor=request.user
  +        ):
               raise ResourceDoesNotExist
   
           if not request.access.has_project_access(project):
  
verification_info: {"golden_diff": "diff --git a/src/sentry/incidents/endpoints/bases.py b/src/sentry/incidents/endpoints/bases.py\n--- a/src/sentry/incidents/endpoints/bases.py\n+++ b/src/sentry/incidents/endpoints/bases.py\n@@ -15,7 +15,10 @@\n         args, kwargs = super().convert_args(request, *args, **kwargs)\n         project = kwargs[\"project\"]\n \n-        if not features.has(\"organizations:incidents\", project.organization, actor=request.user):\n+        # Allow orgs that have downgraded plans to delete metric alerts\n+        if request.method != \"DELETE\" and not features.has(\n+            \"organizations:incidents\", project.organization, actor=request.user\n+        ):\n             raise ResourceDoesNotExist\n \n         if not request.access.has_project_access(project):\n", "issue": "Unable to disable issue alert notifications for specific projects on old sentry accounts.\n### Environment\n\nSaaS (https://sentry.io/)\n\n### Version\n\n_No response_\n\n### Link\n\n_No response_\n\n### DSN\n\n_No response_\n\n### Steps to Reproduce\n\nIn old accounts the default option for Fine tuning issue alert notifications was `--`, which no longer exists. (User Settings -> Notifications -> Issue alert notifications -> Fine Tune).\r\n\r\nIt seems to have been replaced with \"Default\" and in cases a user wants to disable the notifications for a project that currently has `--` selected, the changes to \"Off\" is not saved and notifications continue to be sent. \r\n\r\nThere is no workaround as turning issue alerts notifications to OFF completely disable the notifications for all projects in all organisation, not allowing to enable for projects that man wants to receive notifications from. \r\n\r\nAs a side note: This design is not optimal as having \"On\" and \"Default\" is redundant -> you can only set default to On, and when it is off there are no options available (Default(Off) does not exist). \r\n\r\nThere is a recoding available in this [internal ticket (contains personal information)](https://sentry.zendesk.com/agent/tickets/84240)\n\n### Expected Result\n\nChanging the notification from `--` to `Off` saves and stop sending emails.\n\n### Actual Result\n\nThe change is not saved.\n", "before_files": [{"content": "from rest_framework.exceptions import PermissionDenied\nfrom rest_framework.request import Request\n\nfrom sentry import features\nfrom sentry.api.bases.organization import OrganizationAlertRulePermission, OrganizationEndpoint\nfrom sentry.api.bases.project import ProjectAlertRulePermission, ProjectEndpoint\nfrom sentry.api.exceptions import ResourceDoesNotExist\nfrom sentry.incidents.models import AlertRule, AlertRuleTrigger, AlertRuleTriggerAction\n\n\nclass ProjectAlertRuleEndpoint(ProjectEndpoint):\n    permission_classes = (ProjectAlertRulePermission,)\n\n    def convert_args(self, request: Request, alert_rule_id, *args, **kwargs):\n        args, kwargs = super().convert_args(request, *args, **kwargs)\n        project = kwargs[\"project\"]\n\n        if not features.has(\"organizations:incidents\", project.organization, actor=request.user):\n            raise ResourceDoesNotExist\n\n        if not request.access.has_project_access(project):\n            raise PermissionDenied\n\n        try:\n            kwargs[\"alert_rule\"] = AlertRule.objects.get(\n                snuba_query__subscriptions__project=project, id=alert_rule_id\n            )\n        except AlertRule.DoesNotExist:\n            raise ResourceDoesNotExist\n\n        return args, kwargs\n\n\nclass OrganizationAlertRuleEndpoint(OrganizationEndpoint):\n    permission_classes = (OrganizationAlertRulePermission,)\n\n    def convert_args(self, request: Request, alert_rule_id, *args, **kwargs):\n        args, kwargs = super().convert_args(request, *args, **kwargs)\n        organization = kwargs[\"organization\"]\n\n        # Allow orgs that have downgraded plans to delete metric alerts\n        if request.method != \"DELETE\" and not features.has(\n            \"organizations:incidents\", organization, actor=request.user\n        ):\n            raise ResourceDoesNotExist\n\n        try:\n            kwargs[\"alert_rule\"] = AlertRule.objects.get(\n                organization=organization, id=alert_rule_id\n            )\n        except AlertRule.DoesNotExist:\n            raise ResourceDoesNotExist\n\n        return args, kwargs\n\n\nclass OrganizationAlertRuleTriggerEndpoint(OrganizationAlertRuleEndpoint):\n    def convert_args(self, request: Request, alert_rule_trigger_id, *args, **kwargs):\n        args, kwargs = super().convert_args(request, *args, **kwargs)\n        organization = kwargs[\"organization\"]\n        alert_rule = kwargs[\"alert_rule\"]\n\n        if not features.has(\"organizations:incidents\", organization, actor=request.user):\n            raise ResourceDoesNotExist\n\n        try:\n            kwargs[\"alert_rule_trigger\"] = AlertRuleTrigger.objects.get(\n                alert_rule=alert_rule, id=alert_rule_trigger_id\n            )\n        except AlertRuleTrigger.DoesNotExist:\n            raise ResourceDoesNotExist\n\n        return args, kwargs\n\n\nclass OrganizationAlertRuleTriggerActionEndpoint(OrganizationAlertRuleTriggerEndpoint):\n    def convert_args(self, request: Request, alert_rule_trigger_action_id, *args, **kwargs):\n        args, kwargs = super().convert_args(request, *args, **kwargs)\n        organization = kwargs[\"organization\"]\n        trigger = kwargs[\"alert_rule_trigger\"]\n\n        if not features.has(\"organizations:incidents\", organization, actor=request.user):\n            raise ResourceDoesNotExist\n\n        try:\n            kwargs[\"alert_rule_trigger_action\"] = AlertRuleTriggerAction.objects.get(\n                alert_rule_trigger=trigger, id=alert_rule_trigger_action_id\n            )\n        except AlertRuleTriggerAction.DoesNotExist:\n            raise ResourceDoesNotExist\n\n        return args, kwargs\n", "path": "src/sentry/incidents/endpoints/bases.py"}], "after_files": [{"content": "from rest_framework.exceptions import PermissionDenied\nfrom rest_framework.request import Request\n\nfrom sentry import features\nfrom sentry.api.bases.organization import OrganizationAlertRulePermission, OrganizationEndpoint\nfrom sentry.api.bases.project import ProjectAlertRulePermission, ProjectEndpoint\nfrom sentry.api.exceptions import ResourceDoesNotExist\nfrom sentry.incidents.models import AlertRule, AlertRuleTrigger, AlertRuleTriggerAction\n\n\nclass ProjectAlertRuleEndpoint(ProjectEndpoint):\n    permission_classes = (ProjectAlertRulePermission,)\n\n    def convert_args(self, request: Request, alert_rule_id, *args, **kwargs):\n        args, kwargs = super().convert_args(request, *args, **kwargs)\n        project = kwargs[\"project\"]\n\n        # Allow orgs that have downgraded plans to delete metric alerts\n        if request.method != \"DELETE\" and not features.has(\n            \"organizations:incidents\", project.organization, actor=request.user\n        ):\n            raise ResourceDoesNotExist\n\n        if not request.access.has_project_access(project):\n            raise PermissionDenied\n\n        try:\n            kwargs[\"alert_rule\"] = AlertRule.objects.get(\n                snuba_query__subscriptions__project=project, id=alert_rule_id\n            )\n        except AlertRule.DoesNotExist:\n            raise ResourceDoesNotExist\n\n        return args, kwargs\n\n\nclass OrganizationAlertRuleEndpoint(OrganizationEndpoint):\n    permission_classes = (OrganizationAlertRulePermission,)\n\n    def convert_args(self, request: Request, alert_rule_id, *args, **kwargs):\n        args, kwargs = super().convert_args(request, *args, **kwargs)\n        organization = kwargs[\"organization\"]\n\n        # Allow orgs that have downgraded plans to delete metric alerts\n        if request.method != \"DELETE\" and not features.has(\n            \"organizations:incidents\", organization, actor=request.user\n        ):\n            raise ResourceDoesNotExist\n\n        try:\n            kwargs[\"alert_rule\"] = AlertRule.objects.get(\n                organization=organization, id=alert_rule_id\n            )\n        except AlertRule.DoesNotExist:\n            raise ResourceDoesNotExist\n\n        return args, kwargs\n\n\nclass OrganizationAlertRuleTriggerEndpoint(OrganizationAlertRuleEndpoint):\n    def convert_args(self, request: Request, alert_rule_trigger_id, *args, **kwargs):\n        args, kwargs = super().convert_args(request, *args, **kwargs)\n        organization = kwargs[\"organization\"]\n        alert_rule = kwargs[\"alert_rule\"]\n\n        if not features.has(\"organizations:incidents\", organization, actor=request.user):\n            raise ResourceDoesNotExist\n\n        try:\n            kwargs[\"alert_rule_trigger\"] = AlertRuleTrigger.objects.get(\n                alert_rule=alert_rule, id=alert_rule_trigger_id\n            )\n        except AlertRuleTrigger.DoesNotExist:\n            raise ResourceDoesNotExist\n\n        return args, kwargs\n\n\nclass OrganizationAlertRuleTriggerActionEndpoint(OrganizationAlertRuleTriggerEndpoint):\n    def convert_args(self, request: Request, alert_rule_trigger_action_id, *args, **kwargs):\n        args, kwargs = super().convert_args(request, *args, **kwargs)\n        organization = kwargs[\"organization\"]\n        trigger = kwargs[\"alert_rule_trigger\"]\n\n        if not features.has(\"organizations:incidents\", organization, actor=request.user):\n            raise ResourceDoesNotExist\n\n        try:\n            kwargs[\"alert_rule_trigger_action\"] = AlertRuleTriggerAction.objects.get(\n                alert_rule_trigger=trigger, id=alert_rule_trigger_action_id\n            )\n        except AlertRuleTriggerAction.DoesNotExist:\n            raise ResourceDoesNotExist\n\n        return args, kwargs\n", "path": "src/sentry/incidents/endpoints/bases.py"}]}