Skip to content

ref(cells): Rename OrganizationSlugReservation.region_name to cell_name#110177

Merged
lynnagara merged 3 commits intomasterfrom
orgslugreservation-cell-name
Mar 9, 2026
Merged

ref(cells): Rename OrganizationSlugReservation.region_name to cell_name#110177
lynnagara merged 3 commits intomasterfrom
orgslugreservation-cell-name

Conversation

@lynnagara
Copy link
Member

database field keeps the same name, generated migration is a no-op needed only to sync django state

database field keeps the same name, generated migration is a no-op needed only to sync django state
@lynnagara lynnagara requested review from a team as code owners March 7, 2026 00:14
@lynnagara lynnagara requested a review from a team March 7, 2026 00:14
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 7, 2026
Copy link
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.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment on lines 35 to 41
slug = models.SlugField(unique=True, null=False)
organization_id = HybridCloudForeignKey("sentry.organization", null=False, on_delete="CASCADE")
user_id = BoundedBigIntegerField(db_index=True, null=True)
# TODO(cells): rename to cell_name
region_name = models.CharField(max_length=REGION_NAME_LENGTH, null=False)
cell_name = models.CharField(max_length=REGION_NAME_LENGTH, null=False, db_column="region_name")
reservation_type = BoundedBigIntegerField(
choices=OrganizationSlugReservationType.as_choices(),
null=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: An OrganizationSlugReservation instantiation uses the old region_name field, which has been renamed to cell_name, and will cause a TypeError.
Severity: HIGH

Suggested Fix

In src/sentry/services/organization/provisioning.py, update the OrganizationSlugReservation instantiation inside the handle_possible_organization_slug_swap function to use the new field name. Change region_name=region_name to cell_name=region_name.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/sentry/models/organizationslugreservation.py#L35-L41

Potential issue: The `OrganizationSlugReservation` model's `region_name` field was
renamed to `cell_name`. However, an instantiation of this model within the `else` block
of the `handle_possible_organization_slug_swap` function was not updated to reflect this
change. It still attempts to pass a `region_name` keyword argument. When this code path
is executed—specifically, when an organization is missing a primary slug reservation
during a slug swap—it will raise a `TypeError` because `region_name` is not a recognized
field on the model, causing the operation to fail.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

This PR has a migration; here is the generated SQL for src/sentry/migrations/1049_rename_slugreservation_region_name_to_cell_name.py

for 1049_rename_slugreservation_region_name_to_cell_name in sentry

--
-- Alter field region_name on organizationslugreservation
--
-- (no-op)
--
-- Rename field region_name on organizationslugreservation to cell_name
--
-- (no-op)

@lynnagara lynnagara merged commit 71cae4e into master Mar 9, 2026
77 checks passed
@lynnagara lynnagara deleted the orgslugreservation-cell-name branch March 9, 2026 16:14
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