Conversation
When a self-hosted instance is imported, if that import data has users with `email_unique` defined, and that email address also has an account in saas, the import will fail because of an integrity error on `email_unique`. We cannot trust data in self-hosted imports so we don't want to merge users (like we do with a saas to saas relocation). By blanking the incoming user's `email_unique` value we can create a duplicate user record that the customer will have to de-deduplicate on their own. I briefly considered generating a random suffix for the email address but this could also conflict with existing data, or conflict with legitimate customer data in the future. This felt like the least disruptive and risky change to make. Fixes SENTRY-5NJV
strongs
approved these changes
Jun 26, 2026
strongs
left a comment
Member
There was a problem hiding this comment.
Looks good and I agree with the approach (better than the suffix strategy imo). Would only be worried if there were downstream concerns with the email field being non-unique but the email_unique field heavily implies it's fine
| if self.pk is None and not is_relocated_user: | ||
| # new users should set email_unique | ||
| self.email_unique = self.email | ||
| elif self.pk is None and is_relocated_user and self.email_unique: |
Member
There was a problem hiding this comment.
to verify, we're guaranteed that relocated users never have a set PK ? never need to update a relocated user during the migration for any reason?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a self-hosted instance is imported, if that import data has users with
email_uniquedefined, and that email address also has an account in saas, the import will fail because of an integrity error onemail_unique.We cannot trust data in self-hosted imports so we don't want to merge users (like we do with a saas to saas relocation). By blanking the incoming user's
email_uniquevalue we can create a duplicate user record that the customer will have to de-deduplicate on their own.I briefly considered generating a random suffix for the email address but this could also conflict with existing data, or conflict with legitimate customer data in the future. This felt like the least disruptive and risky change to make.
Fixes SENTRY-5NJV