Skip to content

Commit b656f79

Browse files
fix(api): Fix Celery TypeError with no-argument apply_async (#2575)
* Fix Celery `TypeError` with no-argument `apply_async` * Verify the task actually executed
1 parent 38ec650 commit b656f79

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

sentry_sdk/integrations/celery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def apply_async(*args, **kwargs):
167167

168168
try:
169169
task_started_from_beat = args[1][0] == "BEAT"
170-
except IndexError:
170+
except (IndexError, TypeError):
171171
task_started_from_beat = False
172172

173173
task = args[0]

tests/integrations/celery/test_celery.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,3 +593,18 @@ def dummy_function(*args, **kwargs):
593593
],
594594
headers={},
595595
)
596+
597+
598+
def test_apply_async_no_args(init_celery):
599+
celery = init_celery()
600+
601+
@celery.task
602+
def example_task():
603+
return "success"
604+
605+
try:
606+
result = example_task.apply_async(None, {})
607+
except TypeError:
608+
pytest.fail("Calling `apply_async` without arguments raised a TypeError")
609+
610+
assert result.get() == "success"

0 commit comments

Comments
 (0)