Skip to content

ref(cells): clean up rpc method signatures#111025

Open
lynnagara wants to merge 14 commits intomasterfrom
rpc-methods
Open

ref(cells): clean up rpc method signatures#111025
lynnagara wants to merge 14 commits intomasterfrom
rpc-methods

Conversation

@lynnagara
Copy link
Member

region_name is no longer passed

region_name is no longer passed
@lynnagara lynnagara requested a review from a team as a code owner March 18, 2026 20:47
@lynnagara lynnagara requested a review from a team March 18, 2026 20:47
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 18, 2026
Comment on lines 33 to 39
def clear_key(
self,
*,
cell_name: str | None = None, # TODO(cells): make required when all callers are updated
region_name: str | None = None, # TODO(cells): remove when all callers are updated
cell_name: str,
key: str,
) -> int:
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: The clear_key method signature changed, but several callers were not updated, which will cause a TypeError at runtime.
Severity: HIGH

Suggested Fix

Update all call sites of CellCachingService.clear_key() to remove the region_name keyword argument, aligning them with the new method signature.

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/hybridcloud/rpc/caching/service.py#L33-L39

Potential issue: The `clear_key()` method in `CellCachingService` was updated to remove
the `region_name` parameter from its signature. However, multiple callers of this method
were not updated to reflect this change. Specifically, code paths related to user async
deletion/replication and Sentry App installation replication still attempt to call
`clear_key()` with the `region_name` keyword argument. This will cause a `TypeError` at
runtime when these operations are performed, leading to failures in these background
tasks.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment on lines 33 to 39
def clear_key(
self,
*,
cell_name: str | None = None, # TODO(cells): make required when all callers are updated
region_name: str | None = None, # TODO(cells): remove when all callers are updated
cell_name: str,
key: str,
) -> int:
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: The clear_key method signature changed, but its callers were not updated. They still pass the removed region_name parameter, which will cause a TypeError.
Severity: HIGH

Suggested Fix

Update all call sites of cell_caching_service.clear_key() to stop passing the region_name argument and instead pass the required cell_name argument. For example, change calls from clear_key(..., region_name=cell_name) to clear_key(..., cell_name=cell_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/hybridcloud/rpc/caching/service.py#L33-L39

Potential issue: The `clear_key` method in `CellCachingService` was refactored to remove
the `region_name` parameter and make `cell_name` a required keyword argument. However,
multiple callers in `user.py`, `sentry_app_installation.py`, and `sentry_apps.py` were
not updated to match this new signature. These call sites still attempt to pass
`region_name`, which will result in a `TypeError: clear_key() got an unexpected keyword
argument 'region_name'` at runtime. This will break cache invalidation logic for users
and Sentry App installations during async deletion, replication, and other tasks.

@lynnagara lynnagara requested a review from a team as a code owner March 18, 2026 20:55
@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

Backend Test Failures

Failures on b525669 in this run:

tests/sentry/hybridcloud/rpc/test_caching.py::test_caching_manylog
tests/sentry/hybridcloud/rpc/test_caching.py:195: in test_caching_many
    cell_caching_service.clear_key(
E   TypeError: LocalCellCachingService.clear_key() got an unexpected keyword argument 'region_name'
tests/sentry/hybridcloud/rpc/test_caching.py::test_caching_many_versioninglog
tests/sentry/hybridcloud/rpc/test_caching.py:274: in test_caching_many_versioning
    cell_caching_service.clear_key(
E   TypeError: LocalCellCachingService.clear_key() got an unexpected keyword argument 'region_name'
tests/sentry/hybridcloud/services/test_control_organization_provisioning.py::TestControlOrganizationProvisioning__InControlMode::test_organization_provisioning_before_user_provisioninglog
tests/sentry/hybridcloud/services/test_control_organization_provisioning.py:112: in test_organization_provisioning_before_user_provisioning
    slug = control_organization_provisioning_rpc_service.provision_organization(
E   TypeError: DatabaseBackedControlOrganizationProvisioningService.provision_organization() got an unexpected keyword argument 'region_name'
tests/sentry/hybridcloud/services/test_control_organization_provisioning.py::TestControlOrganizationProvisioning::test_organization_provisioning_before_user_provisioninglog
tests/sentry/hybridcloud/services/test_control_organization_provisioning.py:112: in test_organization_provisioning_before_user_provisioning
    slug = control_organization_provisioning_rpc_service.provision_organization(
E   TypeError: DatabaseBackedControlOrganizationProvisioningService.provision_organization() got an unexpected keyword argument 'region_name'
tests/sentry/hybridcloud/services/test_control_organization_provisioning.py::TestControlOrganizationProvisioning__InCellMode::test_organization_provisioning_before_user_provisioninglog
src/sentry/hybridcloud/rpc/sig.py:127: in serialize_arguments
    model_instance = self._parameter_model(**raw_arguments)
pydantic/main.py:364: in pydantic.main.BaseModel.__init__
    ???
E   pydantic.error_wrappers.ValidationError: 1 validation error for ControlOrganizationProvisioningRpcService__provision_organization__ParameterModel
E   cell_name
E     field required (type=value_error.missing)

The above exception was the direct cause of the following exception:
tests/sentry/hybridcloud/services/test_control_organization_provisioning.py:112: in test_organization_provisioning_before_user_provisioning
    slug = control_organization_provisioning_rpc_service.provision_organization(
src/sentry/hybridcloud/rpc/service.py:353: in remote_method
    serial_arguments = signature.serialize_arguments(kwargs)
src/sentry/hybridcloud/rpc/sig.py:129: in serialize_arguments
    raise SerializableFunctionValueException(self, "Could not serialize arguments") from e
E   sentry.hybridcloud.rpc.sig.SerializableFunctionValueException: ControlOrganizationProvisioningRpcService.provision_organization: Could not serialize arguments
tests/sentry/hybridcloud/rpc/test_caching.py::test_caching_functionlog
tests/sentry/hybridcloud/rpc/test_caching.py:54: in test_caching_function
    cell_caching_service.clear_key(
E   TypeError: LocalCellCachingService.clear_key() got an unexpected keyword argument 'region_name'

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.

Fix All in Cursor

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

organization_slug_reservation_id: int,
cell_name: str | None = None,
region_name: str | None = None,
cell_name,
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing type annotation on cell_name parameter

Low Severity

In delete_replicated_org_slug_reservation, cell_name is missing its : str type annotation. Every other method in DatabaseBackedCellReplicaService annotates it as cell_name: str, and the abstract definition in service.py also declares cell_name: str. This appears to be an accidental omission during the signature cleanup.

Fix in Cursor Fix in Web

@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

Backend Test Failures

Failures on 6e2ef40 in this run:

tests/sentry/hybridcloud/rpc/test_caching.py::test_caching_manylog
tests/sentry/hybridcloud/rpc/test_caching.py:195: in test_caching_many
    cell_caching_service.clear_key(
E   TypeError: LocalCellCachingService.clear_key() got an unexpected keyword argument 'region_name'
tests/sentry/hybridcloud/test_replica.py::test_replicate_auth_provider[CONTROL]log
src/sentry/hybridcloud/rpc/sig.py:127: in serialize_arguments
    model_instance = self._parameter_model(**raw_arguments)
pydantic/main.py:364: in pydantic.main.BaseModel.__init__
    ???
E   pydantic.error_wrappers.ValidationError: 1 validation error for CellReplicaService__upsert_replicated_auth_provider__ParameterModel
E   cell_name
E     field required (type=value_error.missing)

The above exception was the direct cause of the following exception:
tests/sentry/hybridcloud/test_replica.py:108: in test_replicate_auth_provider
    cell_replica_service.upsert_replicated_auth_provider(auth_provider=serialized, region_name="us")
src/sentry/hybridcloud/rpc/service.py:353: in remote_method
    serial_arguments = signature.serialize_arguments(kwargs)
src/sentry/hybridcloud/rpc/sig.py:129: in serialize_arguments
    raise SerializableFunctionValueException(self, "Could not serialize arguments") from e
E   sentry.hybridcloud.rpc.sig.SerializableFunctionValueException: CellReplicaService.upsert_replicated_auth_provider: Could not serialize arguments
tests/sentry/hybridcloud/rpc/test_caching.py::test_caching_functionlog
tests/sentry/hybridcloud/rpc/test_caching.py:54: in test_caching_function
    cell_caching_service.clear_key(
E   TypeError: LocalCellCachingService.clear_key() got an unexpected keyword argument 'region_name'
tests/sentry/hybridcloud/rpc/test_caching.py::test_caching_many_versioninglog
tests/sentry/hybridcloud/rpc/test_caching.py:274: in test_caching_many_versioning
    cell_caching_service.clear_key(
E   TypeError: LocalCellCachingService.clear_key() got an unexpected keyword argument 'region_name'
tests/sentry/hybridcloud/test_replica.py::test_replicate_auth_provider[MONOLITH]log
tests/sentry/hybridcloud/test_replica.py:108: in test_replicate_auth_provider
    cell_replica_service.upsert_replicated_auth_provider(auth_provider=serialized, region_name="us")
E   TypeError: DatabaseBackedCellReplicaService.upsert_replicated_auth_provider() got an unexpected keyword argument 'region_name'
tests/sentry/hybridcloud/test_replica.py::test_replicate_auth_provider[REGION]log
tests/sentry/hybridcloud/test_replica.py:108: in test_replicate_auth_provider
    cell_replica_service.upsert_replicated_auth_provider(auth_provider=serialized, region_name="us")
E   TypeError: DatabaseBackedCellReplicaService.upsert_replicated_auth_provider() got an unexpected keyword argument 'region_name'

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.

1 participant