ref(cells): Rename OrganizationSlugReservation.region_name to cell_name#110177
ref(cells): Rename OrganizationSlugReservation.region_name to cell_name#110177
Conversation
database field keeps the same name, generated migration is a no-op needed only to sync django state
There was a problem hiding this comment.
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.
| 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, |
There was a problem hiding this comment.
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.
|
This PR has a migration; here is the generated SQL for for --
-- Alter field region_name on organizationslugreservation
--
-- (no-op)
--
-- Rename field region_name on organizationslugreservation to cell_name
--
-- (no-op) |
database field keeps the same name, generated migration is a no-op needed only to sync django state