feat(autofix): Add high-level autofix settings update helper#115037
feat(autofix): Add high-level autofix settings update helper#115037
Conversation
chromy
left a comment
There was a problem hiding this comment.
lgtm % a few comments, thank you!
| project.update_option(key, value) | ||
|
|
||
| with transaction.atomic(using=router.db_for_write(ProjectOption)): | ||
| list(Project.objects.select_for_update().filter(id=project.id)) |
There was a problem hiding this comment.
What is the purpose of the list(Project.objects.select_for_update().filter(id=project.id)) line?
There was a problem hiding this comment.
This line is locking the project row to make sure we are serializing concurrent writes and avoiding race conditions. So for example if the endpoint gets hit for the same project at the same time we want to make sure we execute one update before the other.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 372f4a1. Configure here.
Relates to CW-1285 Tldr, add an unused helper and prep stuff for #114899. Adds `update_seer_project_settings`, a helper that translates high-level Seer settings (agent, stopping point, scanner automation) into the underlying project options. This centralizes the write logic so the upcoming bulk and single-project settings endpoints can share it instead of duplicating option-level writes. - **agent=seer**: clears required handoff options (point, target, integration_id) - **agent=cursor/claude**: sets handoff config, requires an integration ID - **stoppingPoint (non-off)**: sets tuning to MEDIUM and stores the stopping point value - **stoppingPoint=off**: sets tuning to OFF; leaves stopping point and auto_create_pr alone so that reenabling tuning restores the prior state - **stoppingPoint=open_pr**: sets auto_create_pr=True; any other stopping point clears it. Safe to set unconditionally since [auto_create_pr is only read when all other handoff options are non-null.](https://github.com/getsentry/sentry/blob/d254733b163432ca88ae796c05d415f97064cbbc/src/sentry/seer/autofix/utils.py#L622) - **stoppingPoint omitted**: tuning and auto_create_pr are left untouched - Options set to their registered default are deleted rather than stored

Relates to CW-1285
Tldr, add an unused helper and prep stuff for #114899.
Adds
update_seer_project_settings, a helper that translates high-level Seer settings (agent, stopping point, scanner automation) into the underlying project options. This centralizes the write logic so the upcoming bulk and single-project settings endpoints can share it instead of duplicating option-level writes.