Skip to content

TypeError raised in the celery integration when calling a task.apply_async without arguments #2554

Closed

Description

@avallbona

How do you use Sentry?

Sentry Saas (sentry.io)

Version

1.36.0

Steps to Reproduce

Having a project with Python 3.9, Django 3.2.23, sentry_sdk>=1.36.0 and celery 5.2.6, with the sentry_sdk configured as:

sentry_sdk.init(
        release=f"project@{VERSION}",
        before_send=before_send,
        before_breadcrumb=before_breadcrumb,
        environment=ENVIRONMENT,
        integrations=[CeleryIntegration(), DjangoIntegration(), RedisIntegration()],
        ignore_errors=SENTRY_IGNORE_EXCEPTIONS,
        send_default_pii=True,
        sample_rate=min(SENTRY_EVENTS_SAMPLE_RATE, 1.0),
        traces_sample_rate=min(SENTRY_TRACES_SAMPLE_RATE, 1.0),
    )

when calling a task directly (not scheduled with celery beat) with the .apply_async() method without params, the sentry_sdk raises a TypeError exception in https://github.com/getsentry/sentry-python/pull/2510/files#diff-bbcc458d29b0f1880cf429abbf8a94a5e8517f61072945d783e44fec4969a10bR169 e.g.:

Traceback (most recent call last):
File "/virtualenv/lib/python3.9/site-packages/celery/app/trace.py", line 451, in trace_task
R = retval = fun(*args, **kwargs)
File "/virtualenv/lib/python3.9/site-packages/sentry_sdk/integrations/celery.py", line 306, in _inner
reraise(*exc_info)
File "/virtualenv/lib/python3.9/site-packages/sentry_sdk/_compat.py", line 115, in reraise
raise value
File "/virtualenv/lib/python3.9/site-packages/sentry_sdk/integrations/celery.py", line 301, in _inner
return f(*args, **kwargs)
File "/virtualenv/lib/python3.9/site-packages/celery/app/trace.py", line 734, in __protected_call__
return self.run(*args, **kwargs)
File "/app/src/virus_scanner/tasks.py", line 79, in load_from_queue
load_from_queue.apply_async()
File "/virtualenv/lib/python3.9/site-packages/celery_common/tasks.py", line 57, in apply_async
return super().apply_async(args, kwargs, **options)
File "/virtualenv/lib/python3.9/site-packages/sentry_sdk/integrations/celery.py", line 169, in apply_async
task_started_from_beat = args[1][0] == "BEAT"
TypeError: 'NoneType' object is not subscriptable

Expected Result

the task is executed properly

Actual Result

a 500 error is raised

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀on Dec 1, 2023
  2. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀on Dec 1, 2023
  3. rodolfoBee commented on Dec 1, 2023

    @rodolfoBee
    Member

    A similar issue was reported in this internal ticket.

  4. moved this to Waiting for: Product Owner in GitHub Issues with 👀on Dec 1, 2023
  5. antonpirker commented on Dec 1, 2023

    @antonpirker
    Contributor

    Hey @avallbona ! Thanks for reporting this! We will take a look!

  6. 17 remaining items

  7. moved this to Waiting for: Product Owner in GitHub Issues with 👀 2on Jan 11, 2024
  8. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 2on Jan 11, 2024
  9. moved this to Waiting for: Community in GitHub Issues with 👀 2on Jan 11, 2024
  10. slapshin commented on Jan 11, 2024

    @slapshin

    @szokeasaurusrex yes, it was my mistake. For now, everything is fine. Thank you!

  11. moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 2on Jan 11, 2024
  12. sentrivana commented on Jan 11, 2024

    @sentrivana
    Collaborator

    Thanks for reporting back @slapshin! I'll close this again.

  13. szokeasaurusrex commented on Jan 11, 2024

    @szokeasaurusrex
    Member

    Good to hear, @slapshin! I am closing the issue for now

  14. ghost added on Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions