Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): Fix Celery TypeError with no-argument apply_async #2575

Merged
merged 3 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/celery.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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"