Skip to content

ref(cells): Remove usage of Region.category#109840

Merged
lynnagara merged 8 commits intomasterfrom
deprecate-region-category
Mar 5, 2026
Merged

ref(cells): Remove usage of Region.category#109840
lynnagara merged 8 commits intomasterfrom
deprecate-region-category

Conversation

@lynnagara
Copy link
Member

@lynnagara lynnagara commented Mar 3, 2026

"category" will be removed from Region/Cell, and will only be a property of locality.

Now there are no more callers to Region.category.

It still exists on the Region dataclass as it's still (temporarily) needed for the 1:1 cell/locality shim.

also simplify TestEnvRegionDirectory

"category" will be removed from Region/Cell, and will only be a property of locality.
Now there are no more callers to Region.category. It still exists as `_category` as
it's still (temporarily) needed for the 1:1 cell/locality shim.
@lynnagara lynnagara requested a review from a team March 3, 2026 21:49
@lynnagara lynnagara requested review from a team as code owners March 3, 2026 21:49
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 3, 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 prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Constructor uses _category but field is named category
    • Updated both incorrect Region constructor calls to use the correct category= keyword so required dataclass validation succeeds.

Create PR

Or push these changes by commenting:

@cursor push 562e5490ca
Preview (562e5490ca)
diff --git a/src/sentry/testutils/helpers/apigateway.py b/src/sentry/testutils/helpers/apigateway.py
--- a/src/sentry/testutils/helpers/apigateway.py
+++ b/src/sentry/testutils/helpers/apigateway.py
@@ -143,7 +143,7 @@
         name="us",
         snowflake_id=1,
         address="http://us.internal.sentry.io",
-        _category=RegionCategory.MULTI_TENANT,
+        category=RegionCategory.MULTI_TENANT,
     )
 
     def setUp(self):

diff --git a/src/sentry/testutils/silo.py b/src/sentry/testutils/silo.py
--- a/src/sentry/testutils/silo.py
+++ b/src/sentry/testutils/silo.py
@@ -91,7 +91,7 @@
             name=name,
             snowflake_id=index + 1,
             address=generate_locality_url(name),
-            _category=(
+            category=(
                 RegionCategory.SINGLE_TENANT
                 if name in single_tenants
                 else RegionCategory.MULTI_TENANT
This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Test Failures

Failures on 7618d25 in this run:

tests/sentry/types/test_region.py::RegionDirectoryTest::test_find_all_multitenant_region_names_non_visiblelog
tests/sentry/types/test_region.py:252: in test_find_all_multitenant_region_names_non_visible
    assert set(result) == {"us", "eu"}
E   AssertionError: assert set() == {'eu', 'us'}
E     
E     Extra items in the right set:
E     'us'
E     'eu'
E     
E     Full diff:
E     + set()
E     - {
E     -     'eu',
E     -     'us',
E     - }
tests/sentry/types/test_region.py::RegionDirectoryTest::test_find_all_multitenant_region_nameslog
tests/sentry/types/test_region.py:234: in test_find_all_multitenant_region_names
    assert set(result) == {"us", "eu"}
E   AssertionError: assert set() == {'eu', 'us'}
E     
E     Extra items in the right set:
E     'us'
E     'eu'
E     
E     Full diff:
E     + set()
E     - {
E     -     'eu',
E     -     'us',
E     - }

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Test Failures

Failures on fb6cbe0 in this run:

tests/sentry/web/test_client_config.py::test_client_config_with_hidden_region_data[CONTROL]log
tests/sentry/web/test_client_config.py:228: in test_client_config_with_hidden_region_data
    assert len(result["regions"]) == 1
E   AssertionError: assert 2 == 1
E    +  where 2 = len([{'name': 'us', 'url': 'http://us.testserver'}, {'name': 'eu', 'url': 'http://eu.testserver'}])
tests/sentry/synapse/endpoints/test_org_cell_mappings.py::OrgCellMappingsTest::test_get_results_no_nextlog
tests/sentry/synapse/endpoints/test_org_cell_mappings.py:72: in test_get_results_no_next
    assert res.data["data"][0] == {"id": str(org1.id), "slug": org1.slug, "cell": "us"}
E   AssertionError: assert {'cell': 'de'...'better-sole'} == {'cell': 'us'...'better-sole'}
E     
E     Omitting 2 identical items, use -vv to show
E     Differing items:
E     {'cell': 'de'} != {'cell': 'us'}
E     
E     Full diff:
E       {
E     -     'cell': 'us',
E     ?              ^^
E     +     'cell': 'de',
E     ?              ^^
E           'id': '4557736349990944',
E           'slug': 'better-sole',
E       }
tests/sentry/web/test_client_config.py::test_client_config_with_multiple_membership[CONTROL]log
tests/sentry/web/test_client_config.py:249: in test_client_config_with_multiple_membership
    assert len(result["regions"]) == 2
E   AssertionError: assert 3 == 2
E    +  where 3 = len([{'name': 'us', 'url': 'http://us.testserver'}, {'name': 'eu', 'url': 'http://eu.testserver'}, {'name': 'acme', 'url': 'http://acme.testserver'}])
tests/sentry/web/test_client_config.py::test_client_config_links_with_priority_org[CONTROL]log
tests/sentry/web/test_client_config.py:344: in test_client_config_links_with_priority_org
    assert result["links"]["regionUrl"] == "http://us.testserver"
E   AssertionError: assert 'http://eu.testserver' == 'http://us.testserver'
E     
E     - http://us.testserver
E     ?         -
E     + http://eu.testserver
E     ?        +
tests/sentry/web/test_client_config.py::test_client_config_links_regionurl[CONTROL]log
tests/sentry/web/test_client_config.py:293: in test_client_config_links_regionurl
    assert result["links"]["regionUrl"] == "http://us.testserver"
E   AssertionError: assert 'http://acme.testserver' == 'http://us.testserver'
E     
E     - http://us.testserver
E     ?        ^^
E     + http://acme.testserver
E     ?        ^^^^
tests/sentry/web/test_api.py::ClientConfigViewTest::test_region_api_url_templatelog
tests/sentry/web/test_api.py:643: in test_region_api_url_template
    assert data["links"] == {
E   AssertionError: assert {'organizatio...//testserver'} == {'organizatio...//testserver'}
E     
E     Omitting 2 identical items, use -vv to show
E     Differing items:
E     {'regionUrl': 'http://foobar.eu.testserver'} != {'regionUrl': 'http://foobar.us.testserver'}
E     
E     Full diff:
E       {
E           'organizationUrl': 'http://baz.testserver',
E     -     'regionUrl': 'http://foobar.us.testserver',
E     ?                                  -
E     +     'regionUrl': 'http://foobar.eu.testserver',
E     ?                                 +
E           'sentryUrl': 'http://testserver',
E       }

def get_cells(self, category: RegionCategory | None = None) -> Iterable[Region]:
return (r for r in self.regions if (category is None or r.category == category))
if category is None:
return iter(self.regions)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return iter(self.regions)
return iter(self._cells)

Comment on lines +174 to +176
r
for r in self.regions
if (loc := self._cell_to_locality.get(r.name)) is not None and loc.category == category
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
r
for r in self.regions
if (loc := self._cell_to_locality.get(r.name)) is not None and loc.category == category
c
for c in self._cells
if (loc := self._cell_to_locality.get(c.name)) is not None and loc.category == category

Should this be _cells as regions is on the way out?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah i can flip those now

@lynnagara lynnagara merged commit 9f0c570 into master Mar 5, 2026
77 checks passed
@lynnagara lynnagara deleted the deprecate-region-category branch March 5, 2026 22:47
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.

2 participants