fix: prevent auto-migration of new teams with matching org slug #25288
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.
What does this PR do?
Fixes a critical bug in the organization onboarding flow where new teams (id === -1) with slugs matching the organization slug were being incorrectly marked for migration instead of being created as new teams.
The Problem:
When a user adds a new team during organization onboarding with a slug that matches the organization slug, the backend was auto-enabling migration for that team. Since new teams have
id === -1, this caused them to be treated as existing teams to migrate, resulting in the team not being created at all.The Solution:
createOrMoveTeamsToOrganizationto prevent moving teams with id === -1Changes:
filterTeamsAndInvitesto accept optionalorgSlugparameterslugConflictsWithOrg && team.id !== -1createOrMoveTeamsToOrganization:team.isBeingMigrated && team.id !== -1Mandatory Tasks
How should this be tested?
Test Scenario 1: New team with matching org slug
Test Scenario 2: Existing team with matching org slug
Test Scenario 3: Teams without names being migrated
Environment:
Human Review Checklist
Critical Items to Verify:
slugConflictsWithOrg && team.id !== -1correctly identifies only existing teams for auto-migrationcreateOrMoveTeamsToOrganizationprevents invalid team movesSession Info:
Checklist