Skip to content

fix(code review): create repo settings even if org's default code review toggle is false#106641

Merged
ryan953 merged 10 commits intomasterfrom
srest2021/fix-repo-settings-bug
Jan 21, 2026
Merged

fix(code review): create repo settings even if org's default code review toggle is false#106641
ryan953 merged 10 commits intomasterfrom
srest2021/fix-repo-settings-bug

Conversation

@srest2021
Copy link
Member

@srest2021 srest2021 commented Jan 21, 2026

Let's always create a RepositorySettings row even if the toggle for the org default is set to False.

Tests need to be updated to use the factory helper as we otherwise will get duplicate key errors trying to insert a row that already exists for that repo.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 21, 2026
@srest2021 srest2021 marked this pull request as ready for review January 21, 2026 00:20
@srest2021 srest2021 requested a review from a team January 21, 2026 00:20
cursor[bot]

This comment was marked as outdated.

@srest2021 srest2021 marked this pull request as draft January 21, 2026 01:41
@srest2021 srest2021 marked this pull request as ready for review January 21, 2026 03:00
cursor[bot]

This comment was marked as outdated.

self.pk = settings.pk
self.save()

return (self.pk, ImportKind.Inserted if created else ImportKind.Overwrite)
Copy link
Member

Choose a reason for hiding this comment

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

Looks like when we're creating a Repository record we'll also create a RepositorySetting.
Then during a database import we'll import the Repository first, which will create some rows inside RepositorySetting with default values. We need to override those rows with this method, setting the correct imported values.

which is the long was of re-phrasing the comment in the method. This method impl matches too: https://github.com/getsentry/sentry/blob/master/src/sentry/users/models/email.py#L51-L63

Copy link
Member Author

@srest2021 srest2021 Jan 21, 2026

Choose a reason for hiding this comment

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

Added some tests for this function in tests/sentry/models/test_repositorysettings.py L83

cursor[bot]

This comment was marked as outdated.

@ryan953 ryan953 force-pushed the srest2021/fix-repo-settings-bug branch from f6c3dfe to 2844fb4 Compare January 21, 2026 06:25
@srest2021 srest2021 changed the title fix(code review): create repo settings even if org default is false fix(code review): create repo settings even if org's default code review toggle is false Jan 21, 2026
Copy link
Member

@JoshFerge JoshFerge left a comment

Choose a reason for hiding this comment

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

changes make sense to me.

@ryan953 ryan953 merged commit 24e5374 into master Jan 21, 2026
99 of 127 checks passed
@ryan953 ryan953 deleted the srest2021/fix-repo-settings-bug branch January 21, 2026 14:59
@github-actions github-actions bot locked and limited conversation to collaborators Feb 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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