Skip to content

Commit

Permalink
fix(api): Fix Celery TypeError with no-argument apply_async (#2575)
Browse files Browse the repository at this point in the history
* Fix Celery `TypeError` with no-argument `apply_async`

* Verify the task actually executed
  • Loading branch information
szokeasaurusrex committed Dec 7, 2023
1 parent 38ec650 commit b656f79
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/celery.py
Expand Up @@ -167,7 +167,7 @@ def apply_async(*args, **kwargs):

try:
task_started_from_beat = args[1][0] == "BEAT"
except IndexError:
except (IndexError, TypeError):
task_started_from_beat = False

task = args[0]
Expand Down
15 changes: 15 additions & 0 deletions tests/integrations/celery/test_celery.py
Expand Up @@ -593,3 +593,18 @@ def dummy_function(*args, **kwargs):
],
headers={},
)


def test_apply_async_no_args(init_celery):
celery = init_celery()

@celery.task
def example_task():
return "success"

try:
result = example_task.apply_async(None, {})
except TypeError:
pytest.fail("Calling `apply_async` without arguments raised a TypeError")

assert result.get() == "success"

0 comments on commit b656f79

Please sign in to comment.