Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/sentry/snuba/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def update_subscription_in_snuba(
[subscription.project_id],
None,
{"organization_id": subscription.project.organization_id},
skip_field_validation_for_entity_subscription_deletion=True,
),
)
)
Expand Down
14 changes: 14 additions & 0 deletions tests/sentry/snuba/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,20 @@ def test_eap_rpc_query_count(self) -> None:
delete_subscription_from_snuba(sub.id)
assert not QuerySubscription.objects.filter(id=sub.id).exists()

def test_invalid_subscription_query(self) -> None:
"""Updating a subscription whose query references a deleted issue should not raise."""
subscription_id = f"1/{uuid4().hex}"
sub = self.create_subscription(
QuerySubscription.Status.UPDATING,
subscription_id=subscription_id,
query="issue:INVALID-1",
)
update_subscription_in_snuba(sub.id)
sub = QuerySubscription.objects.get(id=sub.id)
assert sub.status == QuerySubscription.Status.ACTIVE.value
assert sub.subscription_id is not None
assert sub.subscription_id != subscription_id

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Update test fails on create

Medium Severity

The new test uses issue:INVALID-1 as the current query and does not pass old_query. After the skip-validation delete, _create_in_snuba rebuilds that query without skip_field_validation_for_entity_subscription_deletion, so _issue_filter_converter raises and the task fails with SubscriptionError instead of becoming ACTIVE.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a7ababb. Configure here.



class DeleteSubscriptionFromSnubaTest(BaseSnubaTaskTest):
expected_status = QuerySubscription.Status.DELETING
Expand Down
Loading