Skip to content

Commit

Permalink
chore(autofix): Migrate autofix flags to flagpole (getsentry#76371)
Browse files Browse the repository at this point in the history
This PR adds a new `organizations:autofix` flag that is managed by
flagpole that is a redundancy with the `projects:ai-autofix` flag. We'll
be deleting the latter flag after we enable the new flag via flagpole.
  • Loading branch information
jennmueng authored Aug 17, 2024
1 parent 69e4e96 commit 7243bc1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/sentry/api/endpoints/group_ai_autofix.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ def post(self, request: Request, group: Group) -> Response:

created_at = datetime.now().isoformat()

if not features.has("projects:ai-autofix", group.project):
if not (
features.has("projects:ai-autofix", group.project)
or features.has("organizations:autofix", group.organization)
):
return self._respond_with_error("AI Autofix is not enabled for this project.", 403)

# For now we only send the event that the user is looking at, in the near future we want to send multiple events.
Expand Down
5 changes: 4 additions & 1 deletion src/sentry/api/endpoints/group_autofix_setup_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ def get(self, request: Request, group: Group) -> Response:
"""
Checks if we are able to run Autofix on the given group.
"""
if not features.has("projects:ai-autofix", group.project):
if not (
features.has("projects:ai-autofix", group.project)
or features.has("organizations:autofix", group.organization)
):
return Response({"detail": "Feature not enabled for project"}, status=403)

org: Organization = request.organization
Expand Down
2 changes: 2 additions & 0 deletions src/sentry/features/temporary.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def register_temporary_features(manager: FeatureManager):
manager.add("organizations:auto-size-big-number-widget", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
# Enables the cron job to auto-enable codecov integrations.
manager.add("organizations:auto-enable-codecov", OrganizationFeature, FeatureHandlerStrategy.INTERNAL, api_expose=False)
# Enables Autofix
manager.add("organizations:autofix", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
# Autofix use new strategy without codebase indexing
manager.add("organizations:autofix-disable-codebase-indexing", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, default=False, api_expose=True)
# Enables getting commit sha from git blame for codecov.
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/api/endpoints/test_group_ai_autofix.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
pytestmark = [requires_snuba]


@apply_feature_flag_on_cls("projects:ai-autofix")
@apply_feature_flag_on_cls("organizations:autofix")
class GroupAutofixEndpointTest(APITestCase, SnubaTestCase):
def _get_url(self, group_id: int):
return f"/api/0/issues/{group_id}/autofix/"
Expand Down
4 changes: 2 additions & 2 deletions tests/sentry/api/endpoints/test_group_autofix_setup_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from sentry.testutils.silo import assume_test_silo_mode


@apply_feature_flag_on_cls("projects:ai-autofix")
@apply_feature_flag_on_cls("organizations:autofix")
class GroupAIAutofixEndpointSuccessTest(APITestCase, SnubaTestCase):
def setUp(self):
super().setUp()
Expand Down Expand Up @@ -140,7 +140,7 @@ def test_successful_with_codebase_indexing_disabled_flag(
}


@apply_feature_flag_on_cls("projects:ai-autofix")
@apply_feature_flag_on_cls("organizations:autofix")
class GroupAIAutofixEndpointFailureTest(APITestCase, SnubaTestCase):
def test_no_gen_ai_consent(self):
self.organization.update_option("sentry:gen_ai_consent", False)
Expand Down

0 comments on commit 7243bc1

Please sign in to comment.