Skip to content

Commit c2d86a3

Browse files
srest2021claude
andcommitted
fix(autofix): Ignore default-valued options in has_configured_options check
Projects with autofix_automation_tuning explicitly set to its default (OFF) — e.g. by set_default_project_autofix_automation_tuning at project creation — were incorrectly treated as having configured preferences. This caused read_preference_from_sentry_db to return a SeerProjectPreference with empty repositories instead of None, skipping the fallback path that populates repos from code mappings. Compare option values against their registered defaults so only meaningfully configured options count. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a16fcfa commit c2d86a3

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/sentry/seer/autofix/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,8 @@ def read_preference_from_sentry_db(project: Project) -> SeerProjectPreference |
750750
]
751751

752752
has_configured_options = any(
753-
ProjectOption.objects.isset(project, key) for key in SEER_PROJECT_PREFERENCE_OPTION_KEYS
753+
project.get_option(key) != projectoptions.get_well_known_default(key, project=project)
754+
for key in SEER_PROJECT_PREFERENCE_OPTION_KEYS
754755
)
755756
if not repo_definitions and not has_configured_options:
756757
return None
@@ -797,6 +798,8 @@ def bulk_read_preferences_from_sentry_db(
797798
for project in projects:
798799
has_configured_options = any(
799800
project_options[key][project.id] is not None
801+
and project_options[key][project.id]
802+
!= projectoptions.get_well_known_default(key, project=project)
800803
for key in SEER_PROJECT_PREFERENCE_OPTION_KEYS
801804
)
802805
if project.id not in repo_definitions_by_project and not has_configured_options:

tests/sentry/seer/autofix/test_autofix_utils.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,15 @@ def test_autofix_automation_tuning_alone_creates_preference(self):
13421342
assert result.autofix_automation_tuning == AutofixAutomationTuningSettings.HIGH
13431343
assert result.repositories == []
13441344

1345+
def test_autofix_automation_tuning_default_alone_returns_none(self):
1346+
"""Setting autofix_automation_tuning to its default (OFF) should not count as configured."""
1347+
self.project.update_option(
1348+
"sentry:autofix_automation_tuning", AutofixAutomationTuningSettings.OFF
1349+
)
1350+
1351+
result = read_preference_from_sentry_db(self.project)
1352+
assert result is None
1353+
13451354
def test_project_with_stopping_point_only(self):
13461355
self.project.update_option("sentry:seer_automated_run_stopping_point", "open_pr")
13471356

@@ -1539,6 +1548,15 @@ def test_autofix_automation_tuning_defaults_to_off(self):
15391548
assert pref is not None
15401549
assert pref.autofix_automation_tuning == AutofixAutomationTuningSettings.OFF
15411550

1551+
def test_autofix_automation_tuning_default_alone_returns_none(self):
1552+
"""Setting autofix_automation_tuning to its default (OFF) should not count as configured."""
1553+
self.project1.update_option(
1554+
"sentry:autofix_automation_tuning", AutofixAutomationTuningSettings.OFF
1555+
)
1556+
1557+
result = bulk_read_preferences_from_sentry_db(self.organization.id, [self.project1.id])
1558+
assert result[self.project1.id] is None
1559+
15421560
def test_wrong_organization_excluded(self):
15431561
other_org = self.create_organization()
15441562
SeerProjectRepository.objects.create(

0 commit comments

Comments
 (0)