Skip to content

feat(autofix): Add high-level autofix settings update helper#115037

Merged
srest2021 merged 14 commits intomasterfrom
srest2021/CW-1285-utils-prep
May 7, 2026
Merged

feat(autofix): Add high-level autofix settings update helper#115037
srest2021 merged 14 commits intomasterfrom
srest2021/CW-1285-utils-prep

Conversation

@srest2021
Copy link
Copy Markdown
Member

@srest2021 srest2021 commented May 6, 2026

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.
  • stoppingPoint omitted: tuning and auto_create_pr are left untouched
  • Options set to their registered default are deleted rather than stored

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 6, 2026

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 6, 2026
@srest2021 srest2021 changed the title feat(autofix): Add high-level autofix settings helper feat(autofix): Add high-level autofix settings update helper May 6, 2026
@srest2021 srest2021 marked this pull request as ready for review May 7, 2026 17:03
@srest2021 srest2021 requested a review from a team as a code owner May 7, 2026 17:03
@srest2021 srest2021 requested a review from a team as a code owner May 7, 2026 17:39
@srest2021 srest2021 requested review from JoshFerge and ryan953 May 7, 2026 17:55
Comment thread src/sentry/seer/autofix/utils.py Outdated
Comment thread src/sentry/seer/autofix/utils.py
Comment thread src/sentry/seer/autofix/utils.py
Comment thread src/sentry/seer/autofix/utils.py
Copy link
Copy Markdown
Contributor

@chromy chromy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm % a few comments, thank you!

Comment thread src/sentry/seer/autofix/constants.py Outdated
project.update_option(key, value)

with transaction.atomic(using=router.db_for_write(ProjectOption)):
list(Project.objects.select_for_update().filter(id=project.id))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of the list(Project.objects.select_for_update().filter(id=project.id)) line?

Copy link
Copy Markdown
Member Author

@srest2021 srest2021 May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/sentry/seer/autofix/utils.py Outdated
Comment thread src/sentry/seer/autofix/utils.py Outdated
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread src/sentry/seer/autofix/constants.py Outdated
@srest2021 srest2021 merged commit ce03b07 into master May 7, 2026
68 checks passed
@srest2021 srest2021 deleted the srest2021/CW-1285-utils-prep branch May 7, 2026 22:35
constantinius pushed a commit that referenced this pull request May 8, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants