Skip to content

Conversation

@armenzg
Copy link
Member

@armenzg armenzg commented Nov 25, 2025

I want tasks dealing with deletion to start with sentry.deletions to have consistency with the rest and find them more easily.

@armenzg armenzg self-assigned this Nov 25, 2025
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 25, 2025
},
"delete-pending-groups": {
"task": "deletions:sentry.tasks.delete_pending_groups",
"task": "deletions:sentry.deletions.tasks.delete_pending_groups",
Copy link
Member Author

Choose a reason for hiding this comment

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

@markstory will something break if I rename this task?

"sentry.tasks.beacon",
"sentry.tasks.codeowners.*",
"sentry.tasks.commit_context",
"sentry.tasks.delete_seer_grouping_records",
Copy link
Member Author

Choose a reason for hiding this comment

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

sentry.deletions.* is strongly typed, thus, no need to list this module explicitely.

@armenzg armenzg requested a review from markstory November 25, 2025 20:54
@codecov
Copy link

codecov bot commented Nov 25, 2025

❌ 12 Tests Failed:

Tests completed Failed Passed Skipped
30120 12 30108 241
View the top 3 failed test(s) by shortest run time
tests.sentry.deletions.tasks.test_delete_pending_groups.DeletePendingGroupsTest::test_chunks_large_batches
Stack Traces | 0.072s run time
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1421: in patched
    with self.decoration_helper(patched,
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:141: in __enter__
    return next(self.gen)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1403: in decoration_helper
    arg = exit_stack.enter_context(patching)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:530: in enter_context
    result = _enter(cm)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1479: in __enter__
    self.target = self.getter()
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/pkgutil.py#x1B[0m:528: in resolve_name
    result = getattr(result, p)
#x1B[1m#x1B[31mE   AttributeError: module 'sentry.tasks' has no attribute 'delete_pending_groups'#x1B[0m
tests.sentry.api.helpers.test_group_index.DeleteGroupsTest::test_delete_groups_deletes_seer_records_by_hash
Stack Traces | 0.095s run time
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1421: in patched
    with self.decoration_helper(patched,
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:141: in __enter__
    return next(self.gen)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1403: in decoration_helper
    arg = exit_stack.enter_context(patching)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:530: in enter_context
    result = _enter(cm)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1479: in __enter__
    self.target = self.getter()
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/pkgutil.py#x1B[0m:528: in resolve_name
    result = getattr(result, p)
#x1B[1m#x1B[31mE   AttributeError: module 'sentry.tasks' has no attribute 'delete_seer_grouping_records'#x1B[0m
tests.sentry.core.endpoints.test_project_details.ProjectDeleteTest::test_delete_project_and_delete_grouping_records
Stack Traces | 0.265s run time
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1421: in patched
    with self.decoration_helper(patched,
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:141: in __enter__
    return next(self.gen)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1403: in decoration_helper
    arg = exit_stack.enter_context(patching)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:530: in enter_context
    result = _enter(cm)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1479: in __enter__
    self.target = self.getter()
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/pkgutil.py#x1B[0m:528: in resolve_name
    result = getattr(result, p)
#x1B[1m#x1B[31mE   AttributeError: module 'sentry.tasks' has no attribute 'delete_seer_grouping_records'#x1B[0m
tests.sentry.deletions.test_group.DeleteGroupTest::test_delete_groups_delete_grouping_records_by_hash
Stack Traces | 0.652s run time
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1421: in patched
    with self.decoration_helper(patched,
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:141: in __enter__
    return next(self.gen)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1403: in decoration_helper
    arg = exit_stack.enter_context(patching)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:530: in enter_context
    result = _enter(cm)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1479: in __enter__
    self.target = self.getter()
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/pkgutil.py#x1B[0m:528: in resolve_name
    result = getattr(result, p)
#x1B[1m#x1B[31mE   AttributeError: module 'sentry.tasks' has no attribute 'delete_seer_grouping_records'#x1B[0m
tests.sentry.deletions.test_group.DeleteGroupTest::test_invalid_group_type_handling
Stack Traces | 0.655s run time
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1421: in patched
    with self.decoration_helper(patched,
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:141: in __enter__
    return next(self.gen)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1403: in decoration_helper
    arg = exit_stack.enter_context(patching)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:530: in enter_context
    result = _enter(cm)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1479: in __enter__
    self.target = self.getter()
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/pkgutil.py#x1B[0m:528: in resolve_name
    result = getattr(result, p)
#x1B[1m#x1B[31mE   AttributeError: module 'sentry.tasks' has no attribute 'delete_seer_grouping_records'#x1B[0m
tests.sentry.deletions.tasks.test_delete_seer_grouping_records.TestDeleteSeerGroupingRecordsByHash::test_chunked
Stack Traces | 1.7s run time
#x1B[1m#x1B[.../deletions/tasks/test_delete_seer_grouping_records.py#x1B[0m:51: in test_chunked
    patch(
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1....../x64/lib/python3.13/unittest/mock.py#x1B[0m:1479: in __enter__
    self.target = self.getter()
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1....../x64/lib/python3.13/pkgutil.py#x1B[0m:528: in resolve_name
    result = getattr(result, p)
#x1B[1m#x1B[31mE   AttributeError: module 'sentry.tasks' has no attribute 'delete_seer_grouping_records'#x1B[0m
tests.sentry.core.endpoints.test_organization_index.OrganizationsCreateTest::test_valid_slugs
Stack Traces | 1.73s run time
#x1B[1m#x1B[.../core/endpoints/test_organization_index.py#x1B[0m:190: in test_valid_slugs
    response = self.get_success_response(name=input_slug, slug=input_slug)
#x1B[1m#x1B[.../sentry/testutils/cases.py#x1B[0m:628: in get_success_response
    assert_status_code(response, 200, 300)
#x1B[1m#x1B[.../sentry/testutils/asserts.py#x1B[0m:47: in assert_status_code
    assert minimum <= response.status_code < maximum, (
#x1B[1m#x1B[31mE   AssertionError: (500, b'{"detail":"Internal Error","errorId":null}')#x1B[0m
#x1B[1m#x1B[31mE   assert 500 < 300#x1B[0m
#x1B[1m#x1B[31mE    +  where 500 = <Response status_code=500, "application/json">.status_code#x1B[0m
tests.sentry.deletions.tasks.test_delete_seer_grouping_records.TestDeleteSeerGroupingRecordsByHash::test_called_task_with_too_many_hashes
Stack Traces | 1.78s run time
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1421: in patched
    with self.decoration_helper(patched,
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:141: in __enter__
    return next(self.gen)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1403: in decoration_helper
    arg = exit_stack.enter_context(patching)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:530: in enter_context
    result = _enter(cm)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1479: in __enter__
    self.target = self.getter()
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/pkgutil.py#x1B[0m:528: in resolve_name
    result = getattr(result, p)
#x1B[1m#x1B[31mE   AttributeError: module 'sentry.tasks' has no attribute 'delete_seer_grouping_records'#x1B[0m
tests.sentry.deletions.tasks.test_delete_seer_grouping_records.TestDeleteSeerGroupingRecordsByHash::test_does_not_schedule_task_if_missing_option
Stack Traces | 1.89s run time
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1421: in patched
    with self.decoration_helper(patched,
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:141: in __enter__
    return next(self.gen)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1403: in decoration_helper
    arg = exit_stack.enter_context(patching)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:530: in enter_context
    result = _enter(cm)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1479: in __enter__
    self.target = self.getter()
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/pkgutil.py#x1B[0m:528: in resolve_name
    result = getattr(result, p)
#x1B[1m#x1B[31mE   AttributeError: module 'sentry.tasks' has no attribute 'delete_seer_grouping_records'#x1B[0m
tests.sentry.deletions.tasks.test_delete_seer_grouping_records.TestDeleteSeerGroupingRecordsByHash::test_simple
Stack Traces | 1.9s run time
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1421: in patched
    with self.decoration_helper(patched,
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:141: in __enter__
    return next(self.gen)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1403: in decoration_helper
    arg = exit_stack.enter_context(patching)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:530: in enter_context
    result = _enter(cm)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1479: in __enter__
    self.target = self.getter()
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/pkgutil.py#x1B[0m:528: in resolve_name
    result = getattr(result, p)
#x1B[1m#x1B[31mE   AttributeError: module 'sentry.tasks' has no attribute 'delete_seer_grouping_records'#x1B[0m
tests.sentry.deletions.tasks.test_delete_seer_grouping_records.TestDeleteSeerGroupingRecordsByHash::test_no_group_ids
Stack Traces | 1.9s run time
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1421: in patched
    with self.decoration_helper(patched,
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:141: in __enter__
    return next(self.gen)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1403: in decoration_helper
    arg = exit_stack.enter_context(patching)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:530: in enter_context
    result = _enter(cm)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1479: in __enter__
    self.target = self.getter()
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/pkgutil.py#x1B[0m:528: in resolve_name
    result = getattr(result, p)
#x1B[1m#x1B[31mE   AttributeError: module 'sentry.tasks' has no attribute 'delete_seer_grouping_records'#x1B[0m
tests.sentry.deletions.tasks.test_delete_seer_grouping_records.TestDeleteSeerGroupingRecordsByHash::test_group_without_hashes
Stack Traces | 2.11s run time
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1421: in patched
    with self.decoration_helper(patched,
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:141: in __enter__
    return next(self.gen)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1403: in decoration_helper
    arg = exit_stack.enter_context(patching)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/contextlib.py#x1B[0m:530: in enter_context
    result = _enter(cm)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/unittest/mock.py#x1B[0m:1479: in __enter__
    self.target = self.getter()
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1................../x64/lib/python3.13/pkgutil.py#x1B[0m:528: in resolve_name
    result = getattr(result, p)
#x1B[1m#x1B[31mE   AttributeError: module 'sentry.tasks' has no attribute 'delete_seer_grouping_records'#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

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.

Bug: Task name not updated in decorator

The task name in the @instrumented_task decorator for call_seer_delete_project_grouping_records wasn't updated from sentry.tasks.call_seer_delete_project_grouping_records to sentry.deletions.tasks.call_seer_delete_project_grouping_records. This inconsistency means the task is registered under the old namespace instead of the new sentry.deletions namespace, defeating the purpose of this refactoring and potentially causing task routing issues if the old task name is referenced elsewhere in the codebase.

src/sentry/deletions/tasks/delete_seer_grouping_records.py#L88-L89

@instrumented_task(
name="sentry.tasks.call_seer_delete_project_grouping_records",

Fix in Cursor Fix in Web


Bug: Outdated patch decorator references old module path

Several @patch decorators in test files still reference the old module paths like sentry.tasks.delete_pending_groups.metrics.incr and sentry.tasks.delete_seer_grouping_records.delete_seer_grouping_records_by_hash.apply_async instead of the new sentry.deletions.tasks.* paths. These patches won't work correctly because the modules have been moved, causing the tests to either fail or not properly mock the intended functions.

tests/sentry/deletions/tasks/test_delete_pending_groups.py#L116-L117

@patch("sentry.api.helpers.group_index.delete.delete_groups_for_project.apply_async")
@patch("sentry.tasks.delete_pending_groups.metrics.incr")

tests/sentry/deletions/tasks/test_delete_seer_grouping_records.py#L30-L31

@patch(
"sentry.tasks.delete_seer_grouping_records.delete_seer_grouping_records_by_hash.apply_async"

tests/sentry/deletions/tasks/test_delete_seer_grouping_records.py#L51-L52

patch(
"sentry.tasks.delete_seer_grouping_records.delete_seer_grouping_records_by_hash.apply_async"

Fix in Cursor Fix in Web


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