Skip to content

Commit ac551e9

Browse files
authored
feat(org-options): Add autofix_enabled org option (#80786)
Adds a new option to check whether an org has autofix enabled yet. This is the backend PR for #80785 Should merge this after #80755 to avoid merge conflicts.
1 parent 9562944 commit ac551e9

File tree

7 files changed

+32
-0
lines changed

7 files changed

+32
-0
lines changed

src/sentry/api/endpoints/group_autofix_setup_check.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,8 @@ def get(self, request: Request, group: Group) -> Response:
153153
"codebaseIndexing": {
154154
"ok": codebase_indexing_ok,
155155
},
156+
"autofixEnabled": {
157+
"ok": org.get_option("sentry:autofix_enabled", False),
158+
},
156159
}
157160
)

src/sentry/api/endpoints/organization_details.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
AI_SUGGESTED_SOLUTION,
4646
ALERTS_MEMBER_WRITE_DEFAULT,
4747
ATTACHMENTS_ROLE_DEFAULT,
48+
AUTOFIX_ENABLED_DEFAULT,
4849
DEBUG_FILES_ROLE_DEFAULT,
4950
EVENTS_MEMBER_ADMIN_DEFAULT,
5051
GITHUB_COMMENT_BOT_DEFAULT,
@@ -192,6 +193,12 @@
192193
bool,
193194
HIDE_AI_FEATURES_DEFAULT,
194195
),
196+
(
197+
"autofixEnabled",
198+
"sentry:autofix_enabled",
199+
bool,
200+
AUTOFIX_ENABLED_DEFAULT,
201+
),
195202
(
196203
"githubPRBot",
197204
"sentry:github_pr_bot",
@@ -284,6 +291,7 @@ class OrganizationSerializer(BaseOrganizationSerializer):
284291
isEarlyAdopter = serializers.BooleanField(required=False)
285292
aiSuggestedSolution = serializers.BooleanField(required=False)
286293
hideAiFeatures = serializers.BooleanField(required=False)
294+
autofixEnabled = serializers.BooleanField(required=False)
287295
codecovAccess = serializers.BooleanField(required=False)
288296
githubOpenPRBot = serializers.BooleanField(required=False)
289297
githubNudgeInvite = serializers.BooleanField(required=False)
@@ -673,6 +681,10 @@ class OrganizationDetailsPutSerializer(serializers.Serializer):
673681
help_text="Specify `true` to hide AI features from the organization.",
674682
required=False,
675683
)
684+
autofixEnabled = serializers.BooleanField(
685+
help_text="Specify `true` to enable Autofix for the organization.",
686+
required=False,
687+
)
676688
codecovAccess = serializers.BooleanField(
677689
help_text="Specify `true` to enable Code Coverage Insights. This feature is only available for organizations on the Team plan and above. Learn more about Codecov [here](/product/codecov/).",
678690
required=False,

src/sentry/api/serializers/models/organization.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
AI_SUGGESTED_SOLUTION,
3434
ALERTS_MEMBER_WRITE_DEFAULT,
3535
ATTACHMENTS_ROLE_DEFAULT,
36+
AUTOFIX_ENABLED_DEFAULT,
3637
DATA_CONSENT_DEFAULT,
3738
DEBUG_FILES_ROLE_DEFAULT,
3839
EVENTS_MEMBER_ADMIN_DEFAULT,
@@ -496,6 +497,7 @@ class DetailedOrganizationSerializerResponse(_DetailedOrganizationSerializerResp
496497
metricsActivateLastForGauges: bool
497498
requiresSso: bool
498499
rollbackEnabled: bool
500+
autofixEnabled: bool
499501

500502

501503
class DetailedOrganizationSerializer(OrganizationSerializer):
@@ -605,6 +607,9 @@ def serialize( # type: ignore[explicit-override, override]
605607
"hideAiFeatures": bool(
606608
obj.get_option("sentry:hide_ai_features", HIDE_AI_FEATURES_DEFAULT)
607609
),
610+
"autofixEnabled": bool(
611+
obj.get_option("sentry:autofix_enabled", AUTOFIX_ENABLED_DEFAULT)
612+
),
608613
"githubPRBot": bool(
609614
obj.get_option("sentry:github_pr_bot", GITHUB_COMMENT_BOT_DEFAULT)
610615
),

src/sentry/apidocs/examples/organization_examples.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ class OrganizationExamples:
312312
"codecovAccess": False,
313313
"aiSuggestedSolution": True,
314314
"hideAiFeatures": False,
315+
"autofixEnabled": False,
315316
"githubPRBot": True,
316317
"githubOpenPRBot": True,
317318
"githubNudgeInvite": True,

src/sentry/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@ class InsightModules(Enum):
708708
JOIN_REQUESTS_DEFAULT = True
709709
AI_SUGGESTED_SOLUTION = True
710710
HIDE_AI_FEATURES_DEFAULT = False
711+
AUTOFIX_ENABLED_DEFAULT = False
711712
GITHUB_COMMENT_BOT_DEFAULT = True
712713
ISSUE_ALERTS_THREAD_DEFAULT = True
713714
METRIC_ALERTS_THREAD_DEFAULT = True

tests/sentry/api/endpoints/test_group_autofix_setup_check.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def setUp(self):
3131
source_root="sentry/",
3232
)
3333
self.organization.update_option("sentry:gen_ai_consent_v2024_11_14", True)
34+
self.organization.update_option("sentry:autofix_enabled", True)
3435

3536
@patch(
3637
"sentry.api.endpoints.group_autofix_setup_check.get_repos_and_access",
@@ -82,6 +83,9 @@ def test_successful_setup(self, mock_update_codebase_index, mock_get_repos_and_a
8283
"codebaseIndexing": {
8384
"ok": True,
8485
},
86+
"autofixEnabled": {
87+
"ok": True,
88+
},
8589
}
8690

8791
@with_feature("organizations:autofix-disable-codebase-indexing")
@@ -137,6 +141,9 @@ def test_successful_with_codebase_indexing_disabled_flag(
137141
"codebaseIndexing": {
138142
"ok": True,
139143
},
144+
"autofixEnabled": {
145+
"ok": True,
146+
},
140147
}
141148

142149

tests/sentry/api/endpoints/test_organization_details.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ def test_various_options(self, mock_get_repositories):
705705
"allowMemberInvite": False,
706706
"aiSuggestedSolution": False,
707707
"hideAiFeatures": True,
708+
"autofixEnabled": True,
708709
"githubOpenPRBot": False,
709710
"githubNudgeInvite": False,
710711
"githubPRBot": False,
@@ -772,6 +773,7 @@ def test_various_options(self, mock_get_repositories):
772773
assert options.get("sentry:sampling_mode") == "organization"
773774
assert options.get("sentry:rollback_enabled") is True
774775
assert options.get("sentry:hide_ai_features") is True
776+
assert options.get("sentry:autofix_enabled") is True
775777

776778
# log created
777779
with assume_test_silo_mode_of(AuditLogEntry):
@@ -802,6 +804,7 @@ def test_various_options(self, mock_get_repositories):
802804
assert "to {}".format(data["alertsMemberWrite"]) in log.data["alertsMemberWrite"]
803805
assert "to {}".format(data["aiSuggestedSolution"]) in log.data["aiSuggestedSolution"]
804806
assert "to {}".format(data["hideAiFeatures"]) in log.data["hideAiFeatures"]
807+
assert "to {}".format(data["autofixEnabled"]) in log.data["autofixEnabled"]
805808
assert "to {}".format(data["githubPRBot"]) in log.data["githubPRBot"]
806809
assert "to {}".format(data["githubOpenPRBot"]) in log.data["githubOpenPRBot"]
807810
assert "to {}".format(data["githubNudgeInvite"]) in log.data["githubNudgeInvite"]

0 commit comments

Comments
 (0)