Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/sentry/seer/autofix/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,8 @@ def read_preference_from_sentry_db(project: Project) -> SeerProjectPreference |
]

has_configured_options = any(
ProjectOption.objects.isset(project, key) for key in SEER_PROJECT_PREFERENCE_OPTION_KEYS
project.get_option(key) != projectoptions.get_well_known_default(key, project=project)
for key in SEER_PROJECT_PREFERENCE_OPTION_KEYS
)
if not repo_definitions and not has_configured_options:
return None
Expand Down Expand Up @@ -797,6 +798,8 @@ def bulk_read_preferences_from_sentry_db(
for project in projects:
has_configured_options = any(
project_options[key][project.id] is not None
and project_options[key][project.id]
!= projectoptions.get_well_known_default(key, project=project)
for key in SEER_PROJECT_PREFERENCE_OPTION_KEYS
)
if project.id not in repo_definitions_by_project and not has_configured_options:
Expand Down
18 changes: 18 additions & 0 deletions tests/sentry/seer/autofix/test_autofix_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,15 @@ def test_autofix_automation_tuning_alone_creates_preference(self):
assert result.autofix_automation_tuning == AutofixAutomationTuningSettings.HIGH
assert result.repositories == []

def test_autofix_automation_tuning_default_alone_returns_none(self):
"""Setting autofix_automation_tuning to its default (OFF) should not count as configured."""
self.project.update_option(
"sentry:autofix_automation_tuning", AutofixAutomationTuningSettings.OFF
)

result = read_preference_from_sentry_db(self.project)
assert result is None

def test_project_with_stopping_point_only(self):
self.project.update_option("sentry:seer_automated_run_stopping_point", "open_pr")

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

def test_autofix_automation_tuning_default_alone_returns_none(self):
"""Setting autofix_automation_tuning to its default (OFF) should not count as configured."""
self.project1.update_option(
"sentry:autofix_automation_tuning", AutofixAutomationTuningSettings.OFF
)

result = bulk_read_preferences_from_sentry_db(self.organization.id, [self.project1.id])
assert result[self.project1.id] is None

def test_wrong_organization_excluded(self):
other_org = self.create_organization()
SeerProjectRepository.objects.create(
Expand Down
Loading